<div dir="ltr"><div>I **speculate** that the attributes associated with the "transverse_mercator" variable must be used.</div><div>====================================================<br></div><div>;---Get the source lat/lon grid<br>tas   = f->tasmax(0,0,:,:)</div><div><br></div><div>lat2d = f->grid_latitude<br>lon2d = f->grid_longitude<br>printMinMax(lat2d,0)<br>printMinMax(lon2d,0)<br><br>itm   = f->transverse_mercator<br><br>print(itm)<br>print("itm@latitude_of_projection_origin="+itm@latitude_of_projection_origin)<br>print("itm@longitude_of_central_meridian="+itm@longitude_of_central_meridian)</div><div><br></div><div>; clarity</div><div><br></div><div>lat_shift = itm@latitude_of_projection_origin<br>lon_shift = itm@longitude_of_central_meridian<br></div><div><br></div><div>; apply 'shift'</div><div><br></div><div>lat2d = lat2d + lat_shift<br>lon2d = lon2d + lon_shift<br>printMinMax(lat2d,0)<br>printMinMax(lon2d,0)<br><br>tas@lat2d = lat2d             ; use 'shifted' coordinates<br>tas@lon2d = lon2d<br></div><div>================</div><div><br></div><div>See attached<br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 12:00 PM Dave Allured - NOAA Affiliate via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>I see what's going on.  From your other e-mail, the data file contains two different sets of coordinates.  There are the projection coordinates in meters.  Those are not latitudes and longitudes, therefore not sufficient for NCL.  But the geographic coordinates are also provided.  Double coordinates are frequently encountered in GIS related applications.  Try this:</div><div dir="ltr"><br></div><div dir="ltr">    tas@lat2d=f->grid_latitude<br>    tas@lon2d=f->grid_longitude<br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 11:42 AM S Br <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">If I print tas@lat2d and tas@lon2d, they give the following information.<div><br></div><div>Variable: taslat<br>Type: double<br>Total Size: 896 bytes<br>            112 values<br>Number of Dimensions: 1<br>Dimensions and sizes:        [112]<br>Coordinates:<br>(0)        -102000<br>(1)    -90000<br>(2)     -78000<br>(3)     -66000<br>(4)     -54000<br>(5)     -42000<br>(6)     -30000<br>(7)     -18000<br>(8)     -6000<br>(9)      6000<br>(10)      18000<br>(11)     30000<br>(12)     42000<br>(13)     54000<br>(14)     66000<br>(15)     78000<br>(16)     90000<br>(17)     102000<br>(18)    114000<br>(19)    126000<br>(20)    138000<br>(21)    150000<br>(22)    162000<br>(23)    174000<br>(24)    186000<br>(25)    198000<br>(26)    210000<br>(27)    222000<br>(28)    234000<br>(29)    246000<br>(30)    258000<br>(31)    270000<br>(32)    282000<br>(33)    294000<br>(34)    306000<br>(35)    318000<br>(36)    330000<br>(37)    342000<br>(38)    354000<br>(39)    366000<br>(40)    378000<br>(41)    390000<br>(42)    402000<br>(43)    414000<br>(44)    426000<br>(45)    438000<br>(46)    450000<br>(47)    462000<br>(48)    474000<br>(49)    486000<br>(50)    498000<br>(51)    510000<br>(52)    522000<br>(53)    534000<br>(54)    546000<br>(55)    558000<br>(56)    570000<br>(57)    582000<br>(58)    594000<br>(59)    606000<br>(60)    618000<br>(61)    630000<br>(62)    642000<br>(63)    654000<br>(64)    666000<br>(65)    678000<br>(66)    690000<br>(67)    702000<br>(68)    714000<br>(69)    726000<br>(70)    738000<br>(71)    750000<br>(72)    762000<br>(73)    774000<br>(74)    786000<br>(75)    798000<br>(76)    810000<br>(77)    822000<br>(78)    834000<br>(79)    846000<br>(80)    858000<br>(81)    870000<br>(82)    882000<br>(83)    894000<br>(84)    906000<br>(85)    918000<br>(86)    930000<br>(87)    942000<br>(88)    954000<br>(89)    966000<br>(90)    978000<br>(91)    990000<br>(92)    1002000<br>(93)   1014000<br>(94)   1026000<br>(95)   1038000<br>(96)   1050000<br>(97)   1062000<br>(98)   1074000<br>(99)   1086000<br>(100)  1098000<br>(101)  1110000<br>(102)  1122000<br>(103)  1134000<br>(104)  1146000<br>(105)  1158000<br>(106)  1170000<br>(107)  1182000<br>(108)  1194000<br>(109)  1206000<br>(110)  1218000<br>(111)  1230000<br><br><br>Variable: taslon<br>Type: double<br>Total Size: 656 bytes<br>            82 values<br>Number of Dimensions: 1<br>Dimensions and sizes: [82]<br>Coordinates:<br>(0) -210000<br>(1)    -198000<br>(2)    -186000<br>(3)    -174000<br>(4)    -162000<br>(5)    -150000<br>(6)    -138000<br>(7)    -126000<br>(8)    -114000<br>(9)    -102000<br>(10)   -90000<br>(11)    -78000<br>(12)    -66000<br>(13)    -54000<br>(14)    -42000<br>(15)    -30000<br>(16)    -18000<br>(17)    -6000<br>(18)     6000<br>(19)      18000<br>(20)     30000<br>(21)     42000<br>(22)     54000<br>(23)     66000<br>(24)     78000<br>(25)     90000<br>(26)     102000<br>(27)    114000<br>(28)    126000<br>(29)    138000<br>(30)    150000<br>(31)    162000<br>(32)    174000<br>(33)    186000<br>(34)    198000<br>(35)    210000<br>(36)    222000<br>(37)    234000<br>(38)    246000<br>(39)    258000<br>(40)    270000<br>(41)    282000<br>(42)    294000<br>(43)    306000<br>(44)    318000<br>(45)    330000<br>(46)    342000<br>(47)    354000<br>(48)    366000<br>(49)    378000<br>(50)    390000<br>(51)    402000<br>(52)    414000<br>(53)    426000<br>(54)    438000<br>(55)    450000<br>(56)    462000<br>(57)    474000<br>(58)    486000<br>(59)    498000<br>(60)    510000<br>(61)    522000<br>(62)    534000<br>(63)    546000<br>(64)    558000<br>(65)    570000<br>(66)    582000<br>(67)    594000<br>(68)    606000<br>(69)    618000<br>(70)    630000<br>(71)    642000<br>(72)    654000<br>(73)    666000<br>(74)    678000<br>(75)    690000<br>(76)    702000<br>(77)    714000<br>(78)    726000<br>(79)    738000<br>(80)    750000<br>(81)    762000<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 6:26 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">It is starting to look like there is an error in the attached coordinates.  What are the min and max values of tas@lat2d and tas@lon2d?</div><div dir="ltr"><br></div><div dir="ltr"><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 10:45 AM S Br <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Dennis,<div><div>The data draws on a wrong location and the map boundary is not aligning.</div><div>It should plot over the UK which is about 50-60N.</div><div><br></div><div>Thanks.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 5:41 PM Dennis Shea <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>It helps to give NCL the correct lat/lon array information.</div><div><br></div><div>See attached<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 10:23 AM Dave Allured - NOAA Affiliate via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>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@lat2d, and tas@lon2d.  It is possible that dimensions are mismatched between data and coordinates, for some reason.</div><div><br></div><div>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.<br><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 10:00 AM S Br <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br>Hi Dave,<div>Many thanks for your reply. Sorry I missed to provide the details.</div><div>I have run the following NCL script  and came across the errors given below. </div><div>You can see the attached plot that it draws value throughout the globe. It is supposed to be drawn only over the UK.</div><div>Am I doing something wrong?<br></div><div><br></div><div>;********</div><div>srcFileName="<a href="http://tas_rcp85_land-rcm_uk_12km_01_mon_198012-208011.nc" target="_blank">tas_rcp85_land-rcm_uk_12km_01_mon_198012-208011.nc</a>"<br><br>;---Read File<br>f=addfile(srcFileName,"r")<br>print(f)<br><br>;---Get the source lat/lon grid<br>tas=f->tas(0,0,:,:)<br>tas@lat2d=f->projection_y_coordinate<br>tas@lon2d=f->projection_x_coordinate<br><br>;---Plot data<br>  wks = gsn_open_wks("x11","map")<br><br>  res              = True<br>  res@gsnMaximize  = True     ; maximize plot in frame<br>  res@cnFillOn     = True     ; turn on contour fill<br>  res@cnLinesOn    = False    ; turn off contour fill<br>  res@gsnAddCyclic     = False<br>;   res@mpMinLatF    =  48.0             ; only plot 30S to 30N<br>;   res@mpMaxLatF    =  60.0<br>;  res@mpMinLonF    =  -15.0          ; only plot 30S to 30N<br>;   res@mpMaxLonF    = 6.0<br></div><div> res@mpDataBaseVersion = "MediumRes"<br>   res@mpLandFillColor = "white"<br><br>  plot = gsn_csm_contour_map(wks,tas(:,:),res)<br></div><div><br></div><div>********************</div><div>(0)       is_valid_latlon2d_attr: Warning: The 'lat2d' attribute must either be<br>(0)      the same dimension sizes as the data, or one element larger in both directions.<br>(0)    Your data will most likely not be overlaid on the map correctly.<br>(0)   check_for_y_lat_coord: Warning: Data either does not contain<br>(0)       a valid latitude coordinate array or doesn't contain one at all.<br>(0)       A valid latitude coordinate array should have a 'units'<br>(0)    attribute equal to one of the following values:<br>(0)        'degrees_north' 'degrees-north' 'degree_north' 'degrees north' 'degrees_N' 'Degrees_north' 'degree_N' 'degreeN' 'degreesN' 'deg north'<br>(0)       is_valid_latlon2d_attr: Warning: The 'lon2d' attribute must either be<br>(0)      the same dimension sizes as the data, or one element larger in both directions.<br>(0)    Your data will most likely not be overlaid on the map correctly.<br>(0)   check_for_lon_coord: Warning: Data either does not contain<br>(0) a valid longitude coordinate array or doesn't contain one at all.<br>(0)      A valid longitude coordinate array should have a 'units'<br>(0)   attribute equal to one of the following values:<br>(0)        'degrees_east' 'degrees-east' 'degree_east' 'degrees east' 'degrees_E' 'Degrees_east' 'degree_E' 'degreeE' 'degreesE' 'deg east'<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 4:17 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>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.</div><div><br></div><div>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.</div><div><br></div><div>    <a href="https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml" target="_blank">https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml</a><br></div><div><br></div><div>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 <b>lat2d</b> and <b>lon2d</b>, or alternatively <b>sfXArray</b> and <b>sfYArray</b> 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.</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 25, 2021 at 8:24 AM S Br via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><p style="color:rgb(51,51,51);font-family:Verdana,sans-serif;font-size:12px">Hi All,<br>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.</p><p style="color:rgb(51,51,51);font-family:Verdana,sans-serif;font-size:12px">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.</p><p style="color:rgb(51,51,51);font-family:Verdana,sans-serif;font-size:12px">For your convenience I have attached here a sample NetCDF file.</p><p style="color:rgb(51,51,51);font-family:Verdana,sans-serif;font-size:12px">Thank you.<br>SBR</p></div></blockquote></div></div></div></div></div></div></div></div></blockquote></div></blockquote></div></div></div></div></blockquote></div>
</blockquote></div>
</blockquote></div></div></div>
</blockquote></div>
</blockquote></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div>