[ncl-talk] Regridding from OSGB spatial coordinate to Latitude-longitude in rotated pole coordinates

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Thu Feb 25 11:26:33 MST 2021


It is starting to look like there is an error in the attached coordinates.
What are the min and max values of tas at lat2d and tas at lon2d?


On Thu, Feb 25, 2021 at 10:45 AM S Br <sbr.climate at gmail.com> wrote:

> Hi Dennis,
> The data draws on a wrong location and the map boundary is not aligning.
> It should plot over the UK which is about 50-60N.
>
> Thanks.
>
> On Thu, Feb 25, 2021 at 5:41 PM Dennis Shea <shea at ucar.edu> wrote:
>
>> It helps to give NCL the correct lat/lon array information.
>>
>> See attached
>>
>> On Thu, Feb 25, 2021 at 10:23 AM Dave Allured - NOAA Affiliate via
>> ncl-talk <ncl-talk at mailman.ucar.edu> wrote:
>>
>>> That script looks pretty good.  You can see from the error messages that
>>> NCL is trying to understand @lat2d and @lon2d, but something is not quite
>>> right with them.  We need to see printVarSummary for tas, tas at lat2d,
>>> and tas at lon2d.  It is possible that dimensions are mismatched between
>>> data and coordinates, for some reason.
>>>
>>> There is also this note in that doc page:  "If your data variable is a
>>> two-dimensional (2D) array ordered lon x lat, you will need to reorder it
>>> to be lat x lon."  Please check and see if this is the problem.
>>>
>>>
>>> On Thu, Feb 25, 2021 at 10:00 AM S Br <sbr.climate at gmail.com> wrote:
>>>
>>>>
>>>> Hi Dave,
>>>> Many thanks for your reply. Sorry I missed to provide the details.
>>>> I have run the following NCL script  and came across the errors given
>>>> below.
>>>> You can see the attached plot that it draws value throughout the globe.
>>>> It is supposed to be drawn only over the UK.
>>>> Am I doing something wrong?
>>>>
>>>> ;********
>>>> srcFileName="tas_rcp85_land-rcm_uk_12km_01_mon_198012-208011.nc"
>>>>
>>>> ;---Read File
>>>> f=addfile(srcFileName,"r")
>>>> print(f)
>>>>
>>>> ;---Get the source lat/lon grid
>>>> tas=f->tas(0,0,:,:)
>>>> tas at lat2d=f->projection_y_coordinate
>>>> tas at lon2d=f->projection_x_coordinate
>>>>
>>>> ;---Plot data
>>>>   wks = gsn_open_wks("x11","map")
>>>>
>>>>   res              = True
>>>>   res at gsnMaximize  = True     ; maximize plot in frame
>>>>   res at cnFillOn     = True     ; turn on contour fill
>>>>   res at cnLinesOn    = False    ; turn off contour fill
>>>>   res at gsnAddCyclic     = False
>>>> ;   res at mpMinLatF    =  48.0             ; only plot 30S to 30N
>>>> ;   res at mpMaxLatF    =  60.0
>>>> ;  res at mpMinLonF    =  -15.0          ; only plot 30S to 30N
>>>> ;   res at mpMaxLonF    = 6.0
>>>>  res at mpDataBaseVersion = "MediumRes"
>>>>    res at mpLandFillColor = "white"
>>>>
>>>>   plot = gsn_csm_contour_map(wks,tas(:,:),res)
>>>>
>>>> ********************
>>>> (0) is_valid_latlon2d_attr: Warning: The 'lat2d' attribute must either
>>>> be
>>>> (0) the same dimension sizes as the data, or one element larger in both
>>>> directions.
>>>> (0) Your data will most likely not be overlaid on the map correctly.
>>>> (0) check_for_y_lat_coord: Warning: Data either does not contain
>>>> (0) a valid latitude coordinate array or doesn't contain one at all.
>>>> (0) A valid latitude coordinate array should have a 'units'
>>>> (0) attribute equal to one of the following values:
>>>> (0)    'degrees_north' 'degrees-north' 'degree_north' 'degrees north'
>>>> 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'
>>>> (0) is_valid_latlon2d_attr: Warning: The 'lon2d' attribute must either
>>>> be
>>>> (0) the same dimension sizes as the data, or one element larger in both
>>>> directions.
>>>> (0) Your data will most likely not be overlaid on the map correctly.
>>>> (0) check_for_lon_coord: Warning: Data either does not contain
>>>> (0) a valid longitude coordinate array or doesn't contain one at all.
>>>> (0) A valid longitude coordinate array should have a 'units'
>>>> (0) attribute equal to one of the following values:
>>>> (0)    'degrees_east' 'degrees-east' 'degree_east' 'degrees east'
>>>> 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'
>>>>
>>>> On Thu, Feb 25, 2021 at 4:17 PM Dave Allured - NOAA Affiliate <
>>>> dave.allured at noaa.gov> wrote:
>>>>
>>>>> Does your file contain its own lat and lon coordinate arrays?  You
>>>>> will need to check this yourself with ncdump or NCL plus print commands.
>>>>>
>>>>> If the file has its own coordinate arrays, then do not regrid or
>>>>> reproject.  Doing that will lose detail and reduce the quality of the
>>>>> plotted image.  NCL is quite capable of directly displaying any data with
>>>>> attached coordinate arrays, and it does not need to know anything about the
>>>>> projection of the data.  Please see documentation for "Plotting data on a
>>>>> map" for much more information about aligning data on a map plot.
>>>>>
>>>>>     https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml
>>>>>
>>>>> If the coordinate arrays in the file are two dimensional, then see
>>>>> example 3, "Curvilinear grid".  When you have 2-D coordinates, they must be
>>>>> passed to the NCL plot routine with special attributes *lat2d* and
>>>>> *lon2d*, or alternatively *sfXArray* and *sfYArray* attached to the
>>>>> plot resource variable.  Note that 1-D coordinates do not need this special
>>>>> treatment because they are normally attached directly to the data variable
>>>>> to plot.
>>>>>
>>>>>
>>>>> On Thu, Feb 25, 2021 at 8:24 AM S Br via ncl-talk <
>>>>> ncl-talk at mailman.ucar.edu> wrote:
>>>>>
>>>>>> Hi All,
>>>>>> I have a set of regional gridded data in the British National Grid
>>>>>> (OSGB) spatial coordinate system. I am looking to use this data in NCL but
>>>>>> the projection is not correctly displayed? Could it be possible to regrid
>>>>>> this data to Latitude-longitude in rotated pole coordinates or to a regular
>>>>>> lat/lon grid.
>>>>>>
>>>>>> I would like to mention that these data sets are generated using the
>>>>>> Iris package in Python. The data is correctly displayed in Python but not
>>>>>> in NCL.
>>>>>>
>>>>>> For your convenience I have attached here a sample NetCDF file.
>>>>>>
>>>>>> Thank you.
>>>>>> SBR
>>>>>>
>>>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at mailman.ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210225/830f59e1/attachment.html>


More information about the ncl-talk mailing list