<div dir="ltr"><div>Hi Karin,</div><div>Thanks for trying this. The data is certainly working fine with Python. Please find the script here.</div><div>I don't have expertise in Python but took help from one of my colleagues. </div><div><br></div><div>import iris<br>import iris.analysis<br>import iris.plot as iplt<br>import matplotlib.pyplot as plt<br>import iris.quickplot as qplt<br><br>file1 = '<a href="http://tasmax_rcp85_land-rcm_uk_12km_time10.nc">tasmax_rcp85_land-rcm_uk_12km_time10.nc</a>'<br>cubes1 = iris.load(file1)<br>print(cubes1)<br>#tas1 = cubes1[1]<br>#print(tas1)<br><br>plt.figure(figsize=(10,10))<br>plt.subplot(1, 2, 1)<br>iplt.pcolormesh(cubes1[1][0,0,:,:])<br>plt.title('Original grid')<br>ax = plt.gca()<br>ax.coastlines()<br>ax.gridlines()<br>plt.tight_layout()<br>plt.show()<br>ax = plt.gca()<br>ax.coastlines(resolution='50m')<br>ax.gridlines()<br>plt.tight_layout()<br>plt.show()<br></div><div><br></div><div>Thanks.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 1, 2021 at 11:12 AM Karin Meier-Fleischer 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">As Dave and Dennis already wrote there is something wrong with the <br>
grid_latitude and grid_longitude values. I was not able to get the <br>
correct plot neither with NCL, Python nor CDO.<br>
<br>
How did you create a correct plot with Python? Did you use Iris? It <br>
would be very interesting to see your Python script. Is it possible to <br>
get it?<br>
<br>
-Karin<br>
<br>
<br>
Am 26.02.21 um 17:38 schrieb Dave Allured - NOAA Affiliate via ncl-talk:<br>
> Progress. This proves that arrays grid_latitude and grid_longitude are <br>
> wrong in the input file. This is no longer an NCL problem, except for <br>
> possibly trying to reproject the data using projection parameters. I <br>
> think Dennis already said this projection is not supported in NCL, so <br>
> that would be difficult.<br>
> <br>
> I recommend asking Iris support for help to generate the correct lat and <br>
> lon arrays. You can show them the invalid coordinates directly, leaving <br>
> NCL out of the loop, by sampling the output from:<br>
> <br>
> ncdump -v grid_latitude,grid_longitude <a href="http://file.nc" rel="noreferrer" target="_blank">file.nc</a> <<a href="http://file.nc" rel="noreferrer" target="_blank">http://file.nc</a>><br>
> <br>
> It may also be possible to get the correct coordinate arrays by some <br>
> other method. You might ask the original data provider if they can <br>
> supply the correct lat and lon arrays to match their data. If you can <br>
> get corrected arrays, it would be easy to retrofit them into your <br>
> temperature data file.<br>
> <br>
> <br>
> On Fri, Feb 26, 2021 at 2:34 AM S Br <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a> <br>
> <mailto:<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>>> wrote:<br>
> <br>
> Hi,<br>
> The min and max of f->grid_latitude and f->grid_longitude prints<br>
> wrong information. You can see that the bounding box is not<br>
> surrounding the UK.<br>
> <br>
> (0) min=-0.8710618968191547 max=12.94984143216418<br>
> (0) min=-18.24145632530888 max=-6.580251255557555<br>
> <br>
> Thanks.<br>
> <br>
> On Thu, Feb 25, 2021 at 9:24 PM Dave Allured - NOAA Affiliate<br>
> <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a> <mailto:<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>>> wrote:<br>
> <br>
> Okay. We need to evaluate whether the lat and lon coordinates<br>
> in your file are correct. I see Dennis's other reply, but I am<br>
> suggesting a different approach using only attached coordinates,<br>
> and nothing else. If the Iris package generated your file<br>
> correctly, then nothing else should be needed.<br>
> <br>
> Please show the min and max of f->grid_latitude and<br>
> f->grid_longitude. Don't show the whole array. The command<br>
> *printMinMax (var, 0)* is useful for this. If these coordinate<br>
> sets are correct, then the min and max should be a bounding box<br>
> surrounding the UK.<br>
> <br>
> NCL works best with supplied coordinate arrays, which is the<br>
> method I am recommending here. Python is doing something<br>
> different, perhaps recalculating based on the projection<br>
> information. I don't really care about that, I just want to<br>
> help you get the normal NCL method working.<br>
> <br>
> <br>
> On Thu, Feb 25, 2021 at 1:20 PM S Br <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a><br>
> <mailto:<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>>> wrote:<br>
> <br>
> Hi Dave,<br>
> Please see the attached plot, this is how it looks like if<br>
> we use the above statements.<br>
> It obviously doesn't plot over the UK.<br>
> <br>
> <br>
> On Thu, Feb 25, 2021 at 6:59 PM Dave Allured - NOAA<br>
> Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a><br>
> <mailto:<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>>> wrote:<br>
> <br>
> I see what's going on. From your other e-mail, the data<br>
> file contains two different sets of coordinates. There<br>
> are the projection coordinates in meters. Those are not<br>
> latitudes and longitudes, therefore not sufficient for<br>
> NCL. But the geographic coordinates are also provided. <br>
> Double coordinates are frequently encountered in GIS<br>
> related applications. Try this:<br>
> <br>
> tas@lat2d=f->grid_latitude<br>
> tas@lon2d=f->grid_longitude<br>
> <br>
> <br>
> On Thu, Feb 25, 2021 at 11:42 AM S Br<br>
> <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a> <mailto:<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>>><br>
> wrote:<br>
> <br>
> If I print tas@lat2d and tas@lon2d, they give the<br>
> following information.<br>
> <br>
> 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>
> <br>
> On Thu, Feb 25, 2021 at 6:26 PM Dave Allured - NOAA<br>
> Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a><br>
> <mailto:<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>>> wrote:<br>
> <br>
> It is starting to look like there is an error in<br>
> the attached coordinates. What are the min and<br>
> max values of tas@lat2d and tas@lon2d?<br>
> <br>
> <br>
> On Thu, Feb 25, 2021 at 10:45 AM S Br<br>
> <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a><br>
> <mailto:<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>>> wrote:<br>
> <br>
> Hi Dennis,<br>
> The data draws on a wrong location and the<br>
> map boundary is not aligning.<br>
> It should plot over the UK which is about<br>
> 50-60N.<br>
> <br>
> Thanks.<br>
> <br>
> On Thu, Feb 25, 2021 at 5:41 PM Dennis Shea<br>
> <<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a> <mailto:<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>>> wrote:<br>
> <br>
> It helps to give NCL the correct lat/lon<br>
> array information.<br>
> <br>
> See attached<br>
> <br>
> On Thu, Feb 25, 2021 at 10:23 AM Dave<br>
> Allured - NOAA Affiliate via ncl-talk<br>
> <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
> <mailto:<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>>> wrote:<br>
> <br>
> That script looks pretty good. You<br>
> can see from the error messages that<br>
> NCL is trying to understand @lat2d<br>
> and @lon2d, but something is not<br>
> quite right with them. We need to<br>
> see printVarSummary for tas,<br>
> tas@lat2d, and tas@lon2d. It is<br>
> possible that dimensions are<br>
> mismatched between data and<br>
> coordinates, for some reason.<br>
> <br>
> There is also this note in that doc<br>
> page: "If your data variable is a<br>
> two-dimensional (2D) array ordered<br>
> lon x lat, you will need to reorder<br>
> it to be lat x lon." Please check<br>
> and see if this is the problem.<br>
> <br>
> <br>
> On Thu, Feb 25, 2021 at 10:00 AM S<br>
> Br <<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a><br>
> <mailto:<a href="mailto:sbr.climate@gmail.com" target="_blank">sbr.climate@gmail.com</a>>> wrote:<br>
> <br>
> <br>
> Hi Dave,<br>
> Many thanks for your reply.<br>
> Sorry I missed to provide the<br>
> details.<br>
> I have run the following NCL<br>
> script and came across the<br>
> errors given below.<br>
> You can see the attached plot<br>
> that it draws value throughout<br>
> the globe. It is supposed to be<br>
> drawn only over the UK.<br>
> Am I doing something wrong?<br>
> <br>
> ;********<br>
> srcFileName="<a href="http://tas_rcp85_land-rcm_uk_12km_01_mon_198012-208011.nc" rel="noreferrer" target="_blank">tas_rcp85_land-rcm_uk_12km_01_mon_198012-208011.nc</a><br>
> <<a href="http://tas_rcp85_land-rcm_uk_12km_01_mon_198012-208011.nc" rel="noreferrer" target="_blank">http://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 ;<br>
> maximize plot in frame<br>
> res@cnFillOn = True ;<br>
> turn on contour fill<br>
> res@cnLinesOn = False ;<br>
> turn off contour fill<br>
> res@gsnAddCyclic = False<br>
> ; res@mpMinLatF = 48.0 <br>
> ; only plot 30S to 30N<br>
> ; res@mpMaxLatF = 60.0<br>
> ; res@mpMinLonF = -15.0 <br>
> ; only plot 30S to 30N<br>
> ; res@mpMaxLonF = 6.0<br>
> res@mpDataBaseVersion =<br>
> "MediumRes"<br>
> res@mpLandFillColor = "white"<br>
> <br>
> plot =<br>
> gsn_csm_contour_map(wks,tas(:,:),res)<br>
> <br>
> ********************<br>
> (0) is_valid_latlon2d_attr:<br>
> Warning: The 'lat2d' attribute<br>
> must either be<br>
> (0) the same dimension sizes as<br>
> the data, or one element larger<br>
> in both directions.<br>
> (0) Your data will most likely<br>
> not be overlaid on the map<br>
> correctly.<br>
> (0) check_for_y_lat_coord:<br>
> Warning: Data either does not<br>
> contain<br>
> (0) a valid latitude coordinate<br>
> array or doesn't contain one at all.<br>
> (0) A valid latitude coordinate<br>
> array should have a 'units'<br>
> (0) attribute equal to one of<br>
> the following values:<br>
> (0) 'degrees_north'<br>
> 'degrees-north' 'degree_north'<br>
> 'degrees north' 'degrees_N'<br>
> 'Degrees_north' 'degree_N'<br>
> 'degreeN' 'degreesN' 'deg north'<br>
> (0) is_valid_latlon2d_attr:<br>
> Warning: The 'lon2d' attribute<br>
> must either be<br>
> (0) the same dimension sizes as<br>
> the data, or one element larger<br>
> in both directions.<br>
> (0) Your data will most likely<br>
> not be overlaid on the map<br>
> correctly.<br>
> (0) check_for_lon_coord:<br>
> Warning: Data either does not<br>
> contain<br>
> (0) a valid longitude coordinate<br>
> array or doesn't contain one at all.<br>
> (0) A valid longitude coordinate<br>
> array should have a 'units'<br>
> (0) attribute equal to one of<br>
> the following values:<br>
> (0) 'degrees_east'<br>
> 'degrees-east' 'degree_east'<br>
> 'degrees east' 'degrees_E'<br>
> 'Degrees_east' 'degree_E'<br>
> 'degreeE' 'degreesE' 'deg east'<br>
> <br>
> On Thu, Feb 25, 2021 at 4:17 PM<br>
> Dave Allured - NOAA Affiliate<br>
> <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a><br>
> <mailto:<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>>><br>
> wrote:<br>
> <br>
> Does your file contain its<br>
> own lat and lon coordinate<br>
> arrays? You will need to<br>
> check this yourself with<br>
> ncdump or NCL plus print<br>
> commands.<br>
> <br>
> If the file has its own<br>
> coordinate arrays, then do<br>
> not regrid or reproject. <br>
> Doing that will lose detail<br>
> and reduce the quality of<br>
> the plotted image. NCL is<br>
> quite capable of directly<br>
> displaying any data with<br>
> attached coordinate arrays,<br>
> and it does not need to know<br>
> anything about the<br>
> projection of the data. <br>
> Please see documentation for<br>
> "Plotting data on a map" for<br>
> much more information about<br>
> aligning data on a map plot.<br>
> <br>
> <a href="https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml" rel="noreferrer" target="_blank">https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml</a><br>
> <<a href="https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml" rel="noreferrer" target="_blank">https://www.ncl.ucar.edu/Applications/plot_data_on_map.shtml</a>><br>
> <br>
> If the coordinate arrays in<br>
> the file are two<br>
> dimensional, then see<br>
> example 3, "Curvilinear<br>
> grid". When you have 2-D<br>
> coordinates, they must be<br>
> passed to the NCL plot<br>
> routine with special<br>
> attributes *lat2d* and<br>
> *lon2d*, or alternatively<br>
> *sfXArray* and<br>
> *sfYArray* attached to the<br>
> plot resource variable. <br>
> Note that 1-D coordinates do<br>
> not need this special<br>
> treatment because they are<br>
> normally attached directly<br>
> to the data variable to plot.<br>
> <br>
> <br>
> On Thu, Feb 25, 2021 at 8:24<br>
> AM S Br via ncl-talk<br>
> <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
> <mailto:<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>>><br>
> wrote:<br>
> <br>
> Hi All,<br>
> I have a set of regional<br>
> gridded data in the<br>
> British National Grid<br>
> (OSGB) spatial<br>
> coordinate system. I am<br>
> looking to use this data<br>
> in NCL but the<br>
> projection is not<br>
> correctly displayed?<br>
> Could it be possible to<br>
> regrid this data to<br>
> Latitude-longitude in<br>
> rotated pole coordinates<br>
> or to a regular lat/lon<br>
> grid.<br>
> <br>
> I would like to mention<br>
> that these data sets are<br>
> generated using the Iris<br>
> package in Python. The<br>
> data is correctly<br>
> displayed in Python but<br>
> not in NCL.<br>
> <br>
> For your convenience I<br>
> have attached here a<br>
> sample NetCDF file.<br>
> <br>
> Thank you.<br>
> SBR<br>
> <br>
> <br>
> _______________________________________________<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><br>
> <br>
<br>
-- <br>
Dipl. Geophys. Karin Meier-Fleischer<br>
Visualization Group - NCL, CDO, Python<br>
Application Support<br>
<br>
Deutsches Klimarechenzentrum GmbH (DKRZ)<br>
Bundesstrasse 45a - D20146 Hamburg - Germany<br>
<br>
Phone: +49 (0)40 460094 126<br>
Fax: +49 (0)40 460094 270<br>
E-Mail: <a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a><br>
URL: <a href="http://www.dkrz.de" rel="noreferrer" target="_blank">www.dkrz.de</a><br>
<br>
Geschäftsführer: Prof. Dr. Thomas Ludwig<br>
Sitz der Gesellschaft: Hamburg<br>
Amtsgericht Hamburg HRB 39784<br>
_______________________________________________<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></div>