[ncl-talk] EOF analysis with NARR data (LON, LAT values)

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Wed Jun 17 15:41:21 MDT 2015


Jothiganesh,

> 1) Is there a way to do the subscripting in the EOF code
> by defining lon and lat instead of x and y.

Yes.  Please see the region_ind function.

> 2) Also, the output netcdf file of EOF does not have the
> lon, lat meta data. Instead it has x and y, which does not
> overlay when I tried with NARR plot.

I already mentioned the solution.  You need to copy or retain the
2-dimensional lat and lon arrays from the input file to the output file.
Then create a plot with the projection methods in NARR example 4, which
utilize the 2-D lat and lon arrays.

Alternatively you can copy the Lambert projection parameters and use the
native grid plot method, as in NARR example 1.  But I recommend against
this method because it is prone to subtle offset errors.

Can anyone point us to concise basic documentation for how 2-D coordinates
are structured in a Netcdf file?  The CF website does not include a concise
explanation of 2-D geographic coordinates.

--Dave


On Tue, Jun 16, 2015 at 9:00 PM, Jothi Ganesh Shanmuga Sundaram <
joshanmugasundaram at mix.wvu.edu> wrote:

> Thanks a lot Dave. It's helpful. I tried running without any coordinate
> script, it is running and I was able to generate the EOF and EOF-time
> series netcdf files for the entire domain. I am interested in coordinate
> subscripting as in the EOF example 1.
>
> When I tried to enter the lon lat ranges, the script does not run. It says
> lon is not a dimension or variable. It accepts x or y, but x and y are some
> strange values in the data. If I type ncl_filedump file -v lon, I see the
> values.
>
> Here is the ncl_filedump summary.
>
> short air ( time, y, x )
> ..
> float lat ( y, x )
> ....
> float lon ( y, x )
>
> 1) Is there a way to do the subscripting in the EOF code by defining lon
> and lat instead of x and y.
>
> 2) Also, the output netcdf file of EOF does not have the lon, lat meta
> data. Instead it has x and y, which cannot does not overlay when I tried
> with NARR plot.
>
> Here is my script.
>
> ;Read the NARR data (Air temperature at 2m)
> f = addfile ("air.2m.mon.mean.nc", "r")
>
> ;Define the parameter, convert the format short to float
>  p = short2flt(f->air(::12,:,:))
>
> ;Calculate the weights
> w = sqrt(cos(0.01745329*p&y))  ;  p&y works, but if i enter p&lat, it does
> not work.
> wp = p*conform(p, w, 1)
> copy_VarCoords(p, wp)
>
> t = wp(y|:,x|:,time|:)            ; x and y works, but if i enter lon or
> lat, it does not work.
>
> ;Number of EOF to be calculated
> neof = 3
>
> ;NCL EOF functions
> eof = eofunc_Wrap(t, neof, False)        ;EOF (3modesXlonXlat)
> eof_ts = eofunc_ts_Wrap (t, eof, False)  ;EOF (3modesXtime)
>
> ;Export EOF spatial data as netcdfile
> system ("/bin/rm -f EOFnarr.nc")
> fout = addfile ("EOFnarr.nc", "c")
> fout at title = "EOFs of pre 1971-2013"
> fout->EOF = eof
>
> Regards
> Jothiganesh
>
>
> On Tue, Jun 16, 2015 at 9:58 PM, Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Jothiganesh,
>>
>> Yes you can directly read NARR data and compute EOF's without
>> regridding.  The underlying EOF functions eofunc and eofunc_ts do not use
>> any spatial coordinates.  They operate purely on numeric arrays.
>>
>> The first EOF example uses coordinate subscripting and the lonFlip
>> function.  If you remove both of these methods from the example, then you
>> can compute EOF's over the entire NARR grid.
>>
>> However, to generate valid plots, you will need to retain the NARR
>> coordinate metadata, and modify the plot section to use one of the plotting
>> methods shown on the NARR examples page.
>>
>> I recommend one of the projection methods in NARR example 4, because they
>> use the retained 2-D coordinate grids to directly align the data with the
>> underlying map.  After you get that working, you can switch back to Lambert
>> or some other projection of your choice.
>>
>> --Dave
>>
>>
>> On Tue, Jun 16, 2015 at 6:39 PM, Jothi Ganesh Shanmuga Sundaram <
>> joshanmugasundaram at mix.wvu.edu> wrote:
>>
>>> Hello,
>>>
>>> I use NARR gridded data (349x277 Lambert Conformal Conic grid) in netcdf
>>> format in NCL. I am able to plot graphics without any problem using the
>>> existing script in NCL website.
>>>
>>> I want to do EOF analysis with NARR data. When I tried to use the EOF
>>> script available from NCL website to analyze NARR data, it is not working.
>>> When I checked the data using ncl_file dump the lon, lat formats are very
>>> different. My question is
>>>
>>> 1) Whether I can do EOF analysis in NCL by directly reading NARR data?
>>> If so, I cannot define the LON LAT value, as NARR has a projected
>>> coordinates value?
>>>
>>> 2) Do I need to regrid the NARR curvilinear to rectlinear data before
>>> doing EOF? or Is there a way to convert the format of LON, LAT in grid
>>> without regridding inorder to do EOF analysis in NCL
>>>
>>> Thanks for your help.
>>>
>>> Regards
>>> Jothiganesh
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150617/9953cadf/attachment.html 


More information about the ncl-talk mailing list