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

S Br sbr.climate at gmail.com
Thu Feb 25 09:53:49 MST 2021


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
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210225/9d21c81c/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Figure_RCM.png
Type: image/png
Size: 152812 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210225/9d21c81c/attachment.png>


More information about the ncl-talk mailing list