Re: longitude/latitude problems in the output file after using linint2_Wrap

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed Feb 20 2013 - 15:00:01 MST

Hi Francesc,

You have this in your code:
newlat@units = "degrees_east"

newlon@units = "degrees_north"

The assignments need to be reversed:

newlat@units = "degrees_north"

newlon@units = "degrees_east"

I modified your script to output the original and new grids, and things
look good to me. Script and plot are attached.
Hope that helps..
Adam

On 02/20/2013 02:28 PM, Montane Caminal, Francesc wrote:
>
> Hello,
>
> I reversed the latitude of my original file to use the "linint2_Wrap"
> function because this function wants the grid to be south-to-north
> (see script below). However, after creating a new output file with the
> interpolated values to the new spatial resolution (from 0.5x0.5 to
> 1x1), something strange happened to the coordinates in the new file,
> and it seems like longitude and latitude were switched or similar (see
> attached pic of the spatial pattern of the output data).
>
> Attached is my original netcdf file and the NCL script that I used
> (see below).
>
> Could anyone please help me to find where the error lies?
>
> Did I forget to include any additional line to avoid the problem with
> the coordinates in the output file? I guess I do not need to reverse
> the latitude again before creating the output file.
>
> Any help will be very appreciated!
>
> Thanks,
>
> Francesc
>
> *_INTERPOLATED VALUES IN THE NEW FILE:_*
>
> *_SCRIPT_*:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
>
> begin
>
> print("reading the variables")
>
> setfileoption("nc","MissingToFillValue",False)
>
> a = addfile ("/home/ecolab/CABLE_forcing1/cruncep_tair_2010_1time.nc",
> "r")
>
> temp=a->y
>
> printVarSummary(temp)
>
> temp@_FillValue = -9.99999979021477e+33
>
> temp@missing_value = temp@_FillValue
>
> temp = temp (::-1,:)
>
> printVarSummary(temp)
>
> ;create a sequence for the new values of lat
>
> newlat=fspan(-89.50,89.50,180)
>
> ;create a sequence for the new values of lon
>
> newlon=fspan(-179.50,179.50,360)
>
> newlat@units = "degrees_east"
>
> newlon@units = "degrees_north"
>
> print("new values for long and lat created")
>
> newtemp=linint2_Wrap(temp&lon,temp&lat,temp,True,newlon,newlat,0)
>
> printVarSummary(newtemp)
>
> print("newtemp: min="+min(newtemp)+" max="+max(newtemp))
>
> newtemp!0 = "lat"
>
> newtemp!1 = "lon"
>
> newtemp&lat = newlat
>
> newtemp&lon = newlon
>
> fout=addfile("cruncep_tair_1x1_2010_1time.nc","c")
>
> fout@title="Air temperature in K and interpolated into 1x1 spatial
> resolution for 1 time"
>
> fout->y=newtemp
>
> end
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
______________________________________________________________
Adam Phillips                                asphilli@ucar.edu
NCAR/Climate and Global Dynamics Division       (303) 497-1726
P.O. Box 3000				
Boulder, CO 80307-3000    http://www.cgd.ucar.edu/cas/asphilli



_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

test.gif
Received on Wed Feb 20 15:00:14 2013

This archive was generated by hypermail 2.1.8 : Thu Feb 21 2013 - 11:26:43 MST