Re: FW: I mean regridding the data to a rectiliniear lat / lon grid

From: Dave Allured <dave.allured_at_nyahnyahspammersnyahnyah>
Date: Tue Aug 07 2012 - 16:01:48 MDT

Gualberto,

Here is some untested code to make a list of the Y/X cordinate pairs.
Since you are new to NCL, I suggest that you study this line by line
to see how it works, then try to fix any problems that might come up.
Good luck.

By the way, I can not remember whether the Geotrans software needs
coordinate pairs in Y/X or X/Y order. Please check the Geotrans
documentation, or experiment both ways, and change the sprintf
statement accordingly.

begin
infile = "MMOUT_DOMAIN1.nc"
outfile = "y-x-coordinates.txt"

print ("Read input file coordinates: " + infile)
f = addfile (infile, "r")
nx = dimsizes (f->lon)
ny = dimsizes (f->lat)

print ("nx = " + nx)
print ("ny = " + ny)

lines = new (nx*ny, string)
j = 0

do y = 0, ny-1
   do x = 0, nx-1
      lines(j) = sprintf ("%12.5f", f->lat(y)) + sprintf ("%12.5f", f->lon(x))
      j = j + 1
   end do
end do

print ("Write text file: " + outfile)
asciiwrite (outfile, lines)
end

--Dave

On Tue, Aug 7, 2012 at 2:06 PM, Gualberto Hernández Juárez
<betoic@hotmail.com> wrote:
> Dave,
> How to make the text file, which you mention in the first point.
>
> Thanks
> Gualberto
>
>> Date: Tue, 7 Aug 2012 11:44:09 -0600
>> Subject: Re: I mean regridding the data to a rectiliniear lat /
>> lon grid
>> From: dave.allured@noaa.gov
>> To: betoic@hotmail.com
>> CC: ncl-talk@ucar.edu
>>
>> Here is one way. I am sure there are others.
>>
>> 1. Use NCL to make a text file containing a 1-dimensional ordered
>> list of all X/Y coordinate pairs.
>>
>> 2. Use MPS Geotrans in batch mode to translate the list of
>> coordinates from Lambert Conformal to terrestrial lat/lon. It's free
>> software, and it supports a huge variety of known terrestrial
>> coordinate systems.
>>
>> http://earth-info.nga.mil/GandG/geotrans/
>>
>> 3. Use NCL to read in the translated coordinates, and reshape them
>> into 2-D lat and lon coordinate arrays.
>>
>> 4. Use one of the many NCL regridding functions, plus the 2-D
>> coordinates from step 3, to regrid the data array to a rectilinear
>> grid of your choice.
>>
>> This is an overview. Steps 1 and 3 are fairly straightforward NCL
>> coding. Steps 2 and 4 will involve significant study to get them
>> working correctly. HTH.
>>
>> --Dave
>>
>> On Tue, Aug 7, 2012 at 10:54 AM, Gualberto Hernández Juárez
>> <betoic@hotmail.com> wrote:
>> > I need *regrid* the 2D lat/lon to a rectilinear lat lon.
>> >
>> > any comments will be grateful enough support, I'm new to NCL.
>> >
>> > Thank you,
>> > Gualberto
>> >
>> >
>> >> Date: Tue, 7 Aug 2012 10:41:42 -0600
>> >> From: shea@ucar.edu
>> >> To: betoic@hotmail.com
>> >> CC: ncl-talk@ucar.edu
>> >> Subject: Re: I mean regridding the data to a rectiliniear
>> >> lat /
>> >> lon grid
>> >>
>> >> Technically, this is already a rectilinear grid.
>> >>
>> >> double lat ( lat )
>> >> _CoordinateAxisType : GeoY
>> >> axis : Y
>> >> grid_spacing : 27.0 km
>> >> long_name : y coordinate of projection
>> >> standard_name : projection_y_coordinate
>> >> units : km
>> >>
>> >> double lon ( lon )
>> >> _CoordinateAxisType : GeoX
>> >> axis : X
>> >> grid_spacing : 27.0 km
>> >> long_name : x coordinate of projection
>> >> standard_name : projection_x_coordinate
>> >> units : km
>> >>
>> >> float u10 ( time, lat, lon )
>> >> long_name : 10 m u wind (m/sec)
>> >> _FillValue : -9999
>> >> grid_mapping : Lambert_Conformal
>> >>
>> >> The issue is that the poorly named 'lat' and 'lon' variables
>> >> should be (say) 'y' and 'x'.
>> >>
>> >> Basically, the projection information
>> >>
>> >> character Lambert_Conformal ( ncl_scalar )
>> >> grid_mapping_name : lambert_conformal_conic
>> >> long_name :
>> >> latitude_of_projection_origin : 0
>> >> longitude_of_central_meridian : -124.17
>> >> false_easting : 0
>> >> false_northing : -27
>> >> standard_parallel : 0
>> >> _CoordinateTransformType : Projection
>> >> _CoordinateAxisTypes : GeoX GeoY
>> >> earth_shape : Earth spherical with radius of 6,371,229.0 m
>> >> earth_radius : 6371229
>> >>
>> >> must be used to generate two-dimensional latitude and longitude
>> >> coordinates for each grid point. Then the data can be plotted on the
>> >> lambert map projection. Is this what you want?
>> >>
>> >> *** I have no idea how to do this. Maybe someone else does. ***
>> >>
>> >> Then, if you really want to *regrid* the 2D lat/lon to a rectilinear
>> >> lat lon, you would have to use the ESMF regridding
>> >> http://www.ncl.ucar.edu/Applications/ESMF.shtml
>> >>
>> >>
>> >> On 8/7/12 10:12 AM, Gualberto Hernández Juárez wrote:
>> >> > Hi,
>> >> >
>> >> > I mean regridding the data to a rectiliniear lat / lon grid
>> >> >
>> >> > locate the file in the directory:
>> >> >
>> >> > ftp://ftp.cgd.ucar.edu/incoming/
>> >> >
>> >> > or you can download from this link:
>> >> >
>> >> > https://dl.dropbox.com/u/96409134/MMOUT_DOMAIN1.nc
>> >> >
>> >> > Thanks I'll be awaiting your response.
>> >> > Gualberto
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Aug 7 16:01:59 2012

This archive was generated by hypermail 2.1.8 : Wed Aug 15 2012 - 08:12:08 MDT