From andrew.kren at noaa.gov Thu Sep 1 09:05:16 2022 From: andrew.kren at noaa.gov (Andrew Kren - NOAA Federal) Date: Thu, 1 Sep 2022 11:05:16 -0400 Subject: [ncl-talk] 2d density plot Message-ID: Hi there, I was curious if there is a way in NCL to do a 2d density plot, instead of a simple scatter plot, as I have done below (attached). A colleague of mine suggested this 2d plot would be better to see if there is any relationship. I think I saw one example of "possibly" doing this on the scatter plot examples, but it didn't appear to be what I was looking for when compared to what python does (https://www.python-graph-gallery.com/2d-density-plot/). Many thanks for any suggestions! -- Andrew Kren Meteorologist NOAA's National Weather Service Raleigh Forecast Office 1005 Capability Drive, Suite 300 Raleigh, North Carolina 27606 voice: 919-326-1035 mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ceiling-RA.png Type: image/png Size: 99940 bytes Desc: not available URL: From ehsantaghizadeh at yahoo.com Mon Sep 12 09:28:33 2022 From: ehsantaghizadeh at yahoo.com (Ehsan Taghizadeh) Date: Mon, 12 Sep 2022 15:28:33 +0000 (UTC) Subject: [ncl-talk] short2flt error References: <320124272.1370536.1662996513334.ref@mail.yahoo.com> Message-ID: <320124272.1370536.1662996513334@mail.yahoo.com> Hi everybody,I hope you are doing well.I tried to read "2 metre temperature" from ERA5-Land nc file. This nc file include about 10 years, all months (12 months), all days (365 days), and all hours (24 hours) with size about 7 GB. I used following simple lines: dr = "./"fn = "era5land.nc"fin = addfile(dr+fn, "r")t2mera = fin->t2m(:,::-1,:)printVarSummary(t2mera) Output is like following lines: Type: shortDimensions and sizes:? ?[time | 87648] x [latitude | 151] x [longitude | 251]Coordinates:? ? ? ? ? ? time: [955488..1043135]? ? ? ? ? ? latitude: [25..40]? ? ? ? ? ? longitude: [40..65] However, if I use short2flt as below:t2meras = short2flt(fin->t2m(:,::-1,:)) Following error occurred: fatal:NclMalloc Failed:[errno=12]fatal:Could not coerce values for operationfatal:["Execute.c":8637]:Execute: Error occurred at or near line 2013 in file /usr/local/ncl6.6/lib/ncarg/nclscripts/csm/contributed.ncl Then it mentioned the line with the "short2flt" command. I'll be thankful if I have any help. -----------------------------------------------------------------------------Sincerely,Ehsan Taghizadeh -------------- next part -------------- An HTML attachment was scrubbed... URL: From brownrig at ucar.edu Mon Sep 12 09:44:42 2022 From: brownrig at ucar.edu (Rick Brownrigg) Date: Mon, 12 Sep 2022 09:44:42 -0600 Subject: [ncl-talk] short2flt error In-Reply-To: <320124272.1370536.1662996513334@mail.yahoo.com> References: <320124272.1370536.1662996513334.ref@mail.yahoo.com> <320124272.1370536.1662996513334@mail.yahoo.com> Message-ID: Hi Ehsan, That errno=12 is an out of memory error, so I suspect short2flt() is not the issue. Are you working with really large datasets/arrays? That short array converted to floats will be 6.6GB Rick On Mon, Sep 12, 2022 at 9:30 AM Ehsan Taghizadeh via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Hi everybody, > I hope you are doing well. > I tried to read "2 metre temperature" from ERA5-Land nc file. This nc file > include about 10 years, all months (12 months), all days (365 days), and > all hours (24 hours) with size about 7 GB. I used following simple lines: > > dr = "./" > fn = "era5land.nc" > fin = addfile(dr+fn, "r") > t2mera = fin->t2m(:,::-1,:) > printVarSummary(t2mera) > > Output is like following lines: > > Type: short > Dimensions and sizes: [time | 87648] x [latitude | 151] x [longitude | > 251] > Coordinates: > time: [955488..1043135] > latitude: [25..40] > longitude: [40..65] > > However, if I use short2flt as below: > t2meras = short2flt(fin->t2m(:,::-1,:)) > > Following error occurred: > > fatal:NclMalloc Failed:[errno=12] > fatal:Could not coerce values for operation > fatal:["Execute.c":8637]:Execute: Error occurred at or near line 2013 in > file /usr/local/ncl6.6/lib/ncarg/nclscripts/csm/contributed.ncl > > Then it mentioned the line with the "short2flt" command. > > I'll be thankful if I have any help. > > > *-----------------------------------------------------------------------------* > *Sincerely,* > *Ehsan Taghizadeh* > > _______________________________________________ > 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: From ehsantaghizadeh at yahoo.com Mon Sep 12 10:54:01 2022 From: ehsantaghizadeh at yahoo.com (Ehsan Taghizadeh) Date: Mon, 12 Sep 2022 16:54:01 +0000 (UTC) Subject: [ncl-talk] short2flt error In-Reply-To: References: <320124272.1370536.1662996513334.ref@mail.yahoo.com> <320124272.1370536.1662996513334@mail.yahoo.com> Message-ID: <484101967.1386848.1663001641163@mail.yahoo.com> Dear Rick,The nc file is included a domain including (25-40N, 40-65E) which was downloaded with the attach api script (temp2m09_18.py). As you mentioned the downloaded file has a size more than 6 GB, because of the domain and long term hourly data. Should I break the time period to have smaller size? On the other hand I would like to interpolate temperature on stations location with the attached script (if I assume short2flt has fixed). How could I write these long data (34*10*365), which 34 is number of stations, 10*365 is number of days?In other words, the desired quantity "t2m_int2p_mima" has 3 dimensions; 1st dimension is related to (min, max, avg), 2nd dimension is related to days which is about 10*365,and 3rd dimension is related to stations which is about 34 stations.May I ask how could I write "t2m_int2p_mima" in a table with headers same as below: ?"stid? min(day1) max(day1) avg(day1) min(day2) max(day2) avg(day2) ... min(day10*365) max(day10*365) avg(day10*365)" I'll be thankful for any help. -----------------------------------------------------------------------------Sincerely,Ehsan Taghizadeh On Monday, September 12, 2022 at 08:14:54 PM GMT+4:30, Rick Brownrigg wrote: Hi Ehsan, That errno=12 is an out of memory error, so I suspect short2flt() is not the issue. Are you working with really large datasets/arrays?? That short array converted to floats will be 6.6GB Rick On Mon, Sep 12, 2022 at 9:30 AM Ehsan Taghizadeh via ncl-talk wrote: Hi everybody,I hope you are doing well.I tried to read "2 metre temperature" from ERA5-Land nc file. This nc file include about 10 years, all months (12 months), all days (365 days), and all hours (24 hours) with size about 7 GB. I used following simple lines: dr = "./"fn = "era5land.nc"fin = addfile(dr+fn, "r")t2mera = fin->t2m(:,::-1,:)printVarSummary(t2mera) Output is like following lines: Type: shortDimensions and sizes:? ?[time | 87648] x [latitude | 151] x [longitude | 251]Coordinates:? ? ? ? ? ? time: [955488..1043135]? ? ? ? ? ? latitude: [25..40]? ? ? ? ? ? longitude: [40..65] However, if I use short2flt as below:t2meras = short2flt(fin->t2m(:,::-1,:)) Following error occurred: fatal:NclMalloc Failed:[errno=12]fatal:Could not coerce values for operationfatal:["Execute.c":8637]:Execute: Error occurred at or near line 2013 in file /usr/local/ncl6.6/lib/ncarg/nclscripts/csm/contributed.ncl Then it mentioned the line with the "short2flt" command. I'll be thankful if I have any help. -----------------------------------------------------------------------------Sincerely,Ehsan Taghizadeh _______________________________________________ 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: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: temp2m09_18.py URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: int.ncl Type: application/octet-stream Size: 1288 bytes Desc: not available URL: From brownrig at ucar.edu Mon Sep 12 11:36:34 2022 From: brownrig at ucar.edu (Rick Brownrigg) Date: Mon, 12 Sep 2022 11:36:34 -0600 Subject: [ncl-talk] short2flt error In-Reply-To: <484101967.1386848.1663001641163@mail.yahoo.com> References: <320124272.1370536.1662996513334.ref@mail.yahoo.com> <320124272.1370536.1662996513334@mail.yahoo.com> <484101967.1386848.1663001641163@mail.yahoo.com> Message-ID: Ehsan, I unfortunately don't know the answers to your questions. Perhaps someone else who understands the data can help out. My apologies, Rick On Mon, Sep 12, 2022 at 10:54 AM Ehsan Taghizadeh via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dear Rick, > The nc file is included a domain including (25-40N, 40-65E) which was > downloaded with the attach api script (temp2m09_18.py). As you mentioned > the downloaded file has a size more than 6 GB, because of the domain and > long term hourly data. Should I break the time period to have smaller size? > > On the other hand I would like to interpolate temperature on stations > location with the attached script (if I assume short2flt has fixed). How > could I write these long data (34*10*365), which 34 is number of stations, > 10*365 is number of days? > In other words, the desired quantity "t2m_int2p_mima" has 3 dimensions; > 1st dimension is related to (min, max, avg), 2nd dimension is related to > days which is about 10*365, > and 3rd dimension is related to stations which is about 34 stations. > May I ask how could I write "t2m_int2p_mima" in a table with headers same > as below: > > "stid min(day1) max(day1) avg(day1) min(day2) max(day2) avg(day2) ... > min(day10*365) max(day10*365) avg(day10*365)" > > I'll be thankful for any help. > > > *-----------------------------------------------------------------------------* > *Sincerely,* > > *Ehsan Taghizadeh* > > > > On Monday, September 12, 2022 at 08:14:54 PM GMT+4:30, Rick Brownrigg < > brownrig at ucar.edu> wrote: > > > Hi Ehsan, > > That errno=12 is an out of memory error, so I suspect short2flt() is not > the issue. Are you working with really large datasets/arrays? That short > array converted to floats will be 6.6GB > > Rick > > On Mon, Sep 12, 2022 at 9:30 AM Ehsan Taghizadeh via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > > Hi everybody, > I hope you are doing well. > I tried to read "2 metre temperature" from ERA5-Land nc file. This nc file > include about 10 years, all months (12 months), all days (365 days), and > all hours (24 hours) with size about 7 GB. I used following simple lines: > > dr = "./" > fn = "era5land.nc" > fin = addfile(dr+fn, "r") > t2mera = fin->t2m(:,::-1,:) > printVarSummary(t2mera) > > Output is like following lines: > > Type: short > Dimensions and sizes: [time | 87648] x [latitude | 151] x [longitude | > 251] > Coordinates: > time: [955488..1043135] > latitude: [25..40] > longitude: [40..65] > > However, if I use short2flt as below: > t2meras = short2flt(fin->t2m(:,::-1,:)) > > Following error occurred: > > fatal:NclMalloc Failed:[errno=12] > fatal:Could not coerce values for operation > fatal:["Execute.c":8637]:Execute: Error occurred at or near line 2013 in > file /usr/local/ncl6.6/lib/ncarg/nclscripts/csm/contributed.ncl > > Then it mentioned the line with the "short2flt" command. > > I'll be thankful if I have any help. > > > *-----------------------------------------------------------------------------* > *Sincerely,* > *Ehsan Taghizadeh* > > _______________________________________________ > ncl-talk mailing list > ncl-talk at mailman.ucar.edu > List instructions, subscriber options, unsubscribe: > https://mailman.ucar.edu/mailman/listinfo/ncl-talk > > _______________________________________________ > 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: From dave.allured at noaa.gov Mon Sep 12 12:07:17 2022 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Mon, 12 Sep 2022 12:07:17 -0600 Subject: [ncl-talk] short2flt error In-Reply-To: <484101967.1386848.1663001641163@mail.yahoo.com> References: <320124272.1370536.1662996513334.ref@mail.yahoo.com> <320124272.1370536.1662996513334@mail.yahoo.com> <484101967.1386848.1663001641163@mail.yahoo.com> Message-ID: Ehsan, a standard strategy for large array problems is to add a loop and process the data one time step at a time. Do not try to read the whole array into memory at any time. This assumes that you are interpolating across X and Y, but not time. open input files start a new output file do itime = 0, ntimes-1 read grids for one time step interpolate write result grids for one time step end do close files On Mon, Sep 12, 2022 at 10:54 AM Ehsan Taghizadeh via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dear Rick, > The nc file is included a domain including (25-40N, 40-65E) which was > downloaded with the attach api script (temp2m09_18.py). As you mentioned > the downloaded file has a size more than 6 GB, because of the domain and > long term hourly data. Should I break the time period to have smaller size? > > On the other hand I would like to interpolate temperature on stations > location with the attached script (if I assume short2flt has fixed). How > could I write these long data (34*10*365), which 34 is number of stations, > 10*365 is number of days? > In other words, the desired quantity "t2m_int2p_mima" has 3 dimensions; > 1st dimension is related to (min, max, avg), 2nd dimension is related to > days which is about 10*365, > and 3rd dimension is related to stations which is about 34 stations. > May I ask how could I write "t2m_int2p_mima" in a table with headers same > as below: > > "stid min(day1) max(day1) avg(day1) min(day2) max(day2) avg(day2) ... > min(day10*365) max(day10*365) avg(day10*365)" > > I'll be thankful for any help. > > > *-----------------------------------------------------------------------------* > *Sincerely,* > > *Ehsan Taghizadeh* > > > On Monday, September 12, 2022 at 08:14:54 PM GMT+4:30, Rick Brownrigg < > brownrig at ucar.edu> wrote: > > Hi Ehsan, > > That errno=12 is an out of memory error, so I suspect short2flt() is not > the issue. Are you working with really large datasets/arrays? That short > array converted to floats will be 6.6GB > > Rick > > On Mon, Sep 12, 2022 at 9:30 AM Ehsan Taghizadeh via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > > Hi everybody, > I hope you are doing well. > I tried to read "2 metre temperature" from ERA5-Land nc file. This nc file > include about 10 years, all months (12 months), all days (365 days), and > all hours (24 hours) with size about 7 GB. I used following simple lines: > > dr = "./" > fn = "era5land.nc" > fin = addfile(dr+fn, "r") > t2mera = fin->t2m(:,::-1,:) > printVarSummary(t2mera) > > Output is like following lines: > > Type: short > Dimensions and sizes: [time | 87648] x [latitude | 151] x [longitude | > 251] > Coordinates: > time: [955488..1043135] > latitude: [25..40] > longitude: [40..65] > > However, if I use short2flt as below: > t2meras = short2flt(fin->t2m(:,::-1,:)) > > Following error occurred: > > fatal:NclMalloc Failed:[errno=12] > fatal:Could not coerce values for operation > fatal:["Execute.c":8637]:Execute: Error occurred at or near line 2013 in > file /usr/local/ncl6.6/lib/ncarg/nclscripts/csm/contributed.ncl > > Then it mentioned the line with the "short2flt" command. > > I'll be thankful if I have any help. > > > *-----------------------------------------------------------------------------* > *Sincerely,* > *Ehsan Taghizadeh* > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From kemal.gurer at arb.ca.gov Thu Sep 15 13:22:28 2022 From: kemal.gurer at arb.ca.gov (Gurer, Kemal@ARB) Date: Thu, 15 Sep 2022 19:22:28 +0000 Subject: [ncl-talk] draw order issue Message-ID: Hello ncl'ers, I am trying to plot MPAS grid cells on the top of US map using ncl. I attached the script that plots map and outlines. I can draw maps and MPAS grid cells separately, but I cannot plot map outline on the top of MPAS grid cells even though I set the draw order to "PostDraw". Could you help me to identify what I am doing wrong? Thanks, Kemal. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: mpas_grids.000001.png Type: image/png Size: 44636 bytes Desc: mpas_grids.000001.png URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: mpas_grids.ncl.txt URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: mpas_grids.000002.png Type: image/png Size: 886433 bytes Desc: mpas_grids.000002.png URL: From brownrig at ucar.edu Thu Sep 15 13:39:09 2022 From: brownrig at ucar.edu (Rick Brownrigg) Date: Thu, 15 Sep 2022 13:39:09 -0600 Subject: [ncl-talk] draw order issue In-Reply-To: References: Message-ID: Hi Kemal, What does the plot look like when you try to plot both map and lines together? Have you tried without the mpOutlineDrawOrder resource? Rick On Thu, Sep 15, 2022 at 1:22 PM Gurer, Kemal at ARB via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Hello ncl?ers, > > > > I am trying to plot MPAS grid cells on the top of US map using ncl. I > attached the script that plots map and outlines. I can draw maps and MPAS > grid cells separately, but I cannot plot map outline on the top of MPAS > grid cells even though I set the draw order to ?PostDraw?. Could you help > me to identify what I am doing wrong? > > > > Thanks, > > > > Kemal. > _______________________________________________ > 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: From kemal.gurer at arb.ca.gov Thu Sep 15 13:56:16 2022 From: kemal.gurer at arb.ca.gov (Gurer, Kemal@ARB) Date: Thu, 15 Sep 2022 19:56:16 +0000 Subject: [ncl-talk] draw order issue In-Reply-To: References: Message-ID: Hi Rick, I tried that before. It didn't help. That is, MPAS grid cells are still plotted without map outlines. Kemal. From: Rick Brownrigg Sent: Thursday, September 15, 2022 12:39 PM To: Gurer, Kemal at ARB Cc: ncl-talk at ucar.edu forum Subject: Re: [ncl-talk] draw order issue CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. Hi Kemal, What does the plot look like when you try to plot both map and lines together? Have you tried without the mpOutlineDrawOrder resource? Rick On Thu, Sep 15, 2022 at 1:22 PM Gurer, Kemal at ARB via ncl-talk > wrote: Hello ncl'ers, I am trying to plot MPAS grid cells on the top of US map using ncl. I attached the script that plots map and outlines. I can draw maps and MPAS grid cells separately, but I cannot plot map outline on the top of MPAS grid cells even though I set the draw order to "PostDraw". Could you help me to identify what I am doing wrong? Thanks, Kemal. _______________________________________________ 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: From brownrig at ucar.edu Thu Sep 15 14:38:06 2022 From: brownrig at ucar.edu (Rick Brownrigg) Date: Thu, 15 Sep 2022 14:38:06 -0600 Subject: [ncl-talk] draw order issue In-Reply-To: References: Message-ID: OK, In the script, as presented to us, there are two calls to gsn_csm_map. They have different lat/lon extents and they both assign the result to the variable "map" (I'm suprised there was no error/warning). In any case, the 2nd set of lat/lon extents are off the coast. That second set is what the MPAS appears to be drawing on top of. HTH... Rick On Thu, Sep 15, 2022 at 1:56 PM Gurer, Kemal at ARB wrote: > Hi Rick, > > > > I tried that before. It didn?t help. That is, MPAS grid cells are still > plotted without map outlines. > > > > Kemal. > > > > *From:* Rick Brownrigg > *Sent:* Thursday, September 15, 2022 12:39 PM > *To:* Gurer, Kemal at ARB > *Cc:* ncl-talk at ucar.edu forum > *Subject:* Re: [ncl-talk] draw order issue > > > > *CAUTION: This email originated from outside of the organization. Do not > click links or open attachments unless you recognize the sender and know > the content is safe.* > > Hi Kemal, > > > > What does the plot look like when you try to plot both map and lines > together? Have you tried without the > > mpOutlineDrawOrder resource? > > Rick > > > > On Thu, Sep 15, 2022 at 1:22 PM Gurer, Kemal at ARB via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > > Hello ncl?ers, > > > > I am trying to plot MPAS grid cells on the top of US map using ncl. I > attached the script that plots map and outlines. I can draw maps and MPAS > grid cells separately, but I cannot plot map outline on the top of MPAS > grid cells even though I set the draw order to ?PostDraw?. Could you help > me to identify what I am doing wrong? > > > > Thanks, > > > > Kemal. > > _______________________________________________ > 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: From brownrig at ucar.edu Thu Sep 15 15:49:28 2022 From: brownrig at ucar.edu (Rick Brownrigg) Date: Thu, 15 Sep 2022 15:49:28 -0600 Subject: [ncl-talk] draw order issue In-Reply-To: References: Message-ID: Hmmm...it looks to me everything is working as it expected. Figure 1 looks right. Figure 2 -- yes that's a larger spatial domain and the MPAS cells overwhelm the map. You could try something like making the map outlines white some other contrasting color (and probably would want PostDraw for this purpose). But I'm not sure the resultant map would be any more useful. Figure 3 is again out over the ocean, and is more than half as small a domain, spatially, as Fig 2. A final thought on Fig 2. -- you could play with the opacity of the grid; make it highly translucent. Probably still too dense. HTH... Rick On Thu, Sep 15, 2022 at 3:21 PM Gurer, Kemal at ARB wrote: > Hi Rick, > > > > I feel really bad that I didn?t see invoking map twice. Since I was > playing around with map, I simply forgot to delete the second call. It is > my mistake. I apologize for this mistake and taking your time. > > > > I can now plot the grid cells with map on it. Yet, the problem actually > still persists. I can plot both map grid outlines and MPAS grid cells if I > zoom in very close to the map. Here is the code that I change to play with > map and grid cells: > > > > ; ---------- This plots both map boundaries and MPAS grid cells due to > zooming in on the map at San Francisco Bay. Both of them are visible. > Please see attached figure 1 ---------- > > > > res at mpMinLatF = 36 > > res at mpMaxLatF = 39 ; choose subregion > > res at mpMinLonF = -124 > > res at mpMaxLonF = -121 > > > > map = gsn_csm_map(wks,res) > > > > ; --------- This plots both map boundaries and MPAS grid cells. But, MPAS > grid cells crowd the plot and map and grid cells are not discernible. Map > boundary is just outside of California and Nevada. Please see figure 2 ----- > > > > res at mpMinLatF = 31.5 > > res at mpMaxLatF = 43 ; choose subregion > > res at mpMinLonF = -127.5 > > res at mpMaxLonF = -113 > > > > map = gsn_csm_map(wks,res) > > > > ; -------- This only plots MPAS grid cells. Map boundaries are not > plotted. Map boundary is slightly bigger than the domain covering in Figure > 2. Please see figure 3-------- > > > > res at mpMinLatF = 30 > > res at mpMaxLatF = 35 > > res at mpMinLonF = -130 > > res at mpMaxLonF = -125 > > > > ; ------------------------------------------ > > > > Kemal. > > > > *From:* Rick Brownrigg > *Sent:* Thursday, September 15, 2022 1:38 PM > *To:* Gurer, Kemal at ARB > *Cc:* ncl-talk at ucar.edu forum > *Subject:* Re: [ncl-talk] draw order issue > > > > *CAUTION: This email originated from outside of the organization. Do not > click links or open attachments unless you recognize the sender and know > the content is safe.* > > OK, > > > > In the script, as presented to us, there are two calls to gsn_csm_map. > They have different lat/lon extents and they both assign the result to the > variable "map" (I'm suprised there was no error/warning). In any case, the > 2nd set of lat/lon extents are off the coast. That second set is what the > MPAS appears to be drawing on top of. > > > > HTH... > > Rick > > > > > > On Thu, Sep 15, 2022 at 1:56 PM Gurer, Kemal at ARB > wrote: > > Hi Rick, > > > > I tried that before. It didn?t help. That is, MPAS grid cells are still > plotted without map outlines. > > > > Kemal. > > > > *From:* Rick Brownrigg > *Sent:* Thursday, September 15, 2022 12:39 PM > *To:* Gurer, Kemal at ARB > *Cc:* ncl-talk at ucar.edu forum > *Subject:* Re: [ncl-talk] draw order issue > > > > *CAUTION: This email originated from outside of the organization. Do not > click links or open attachments unless you recognize the sender and know > the content is safe.* > > Hi Kemal, > > > > What does the plot look like when you try to plot both map and lines > together? Have you tried without the > > mpOutlineDrawOrder resource? > > Rick > > > > On Thu, Sep 15, 2022 at 1:22 PM Gurer, Kemal at ARB via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > > Hello ncl?ers, > > > > I am trying to plot MPAS grid cells on the top of US map using ncl. I > attached the script that plots map and outlines. I can draw maps and MPAS > grid cells separately, but I cannot plot map outline on the top of MPAS > grid cells even though I set the draw order to ?PostDraw?. Could you help > me to identify what I am doing wrong? > > > > Thanks, > > > > Kemal. > > _______________________________________________ > 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: From kemal.gurer at arb.ca.gov Thu Sep 15 15:53:17 2022 From: kemal.gurer at arb.ca.gov (Gurer, Kemal@ARB) Date: Thu, 15 Sep 2022 21:53:17 +0000 Subject: [ncl-talk] draw order issue In-Reply-To: References: Message-ID: I agree with your assessment. Thank you very much for your help Rick. With regards. - Kemal. From: Rick Brownrigg Sent: Thursday, September 15, 2022 2:49 PM To: Gurer, Kemal at ARB Cc: ncl-talk at ucar.edu forum Subject: Re: [ncl-talk] draw order issue CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. Hmmm...it looks to me everything is working as it expected. Figure 1 looks right. Figure 2 -- yes that's a larger spatial domain and the MPAS cells overwhelm the map. You could try something like making the map outlines white some other contrasting color (and probably would want PostDraw for this purpose). But I'm not sure the resultant map would be any more useful. Figure 3 is again out over the ocean, and is more than half as small a domain, spatially, as Fig 2. A final thought on Fig 2. -- you could play with the opacity of the grid; make it highly translucent. Probably still too dense. HTH... Rick On Thu, Sep 15, 2022 at 3:21 PM Gurer, Kemal at ARB > wrote: Hi Rick, I feel really bad that I didn't see invoking map twice. Since I was playing around with map, I simply forgot to delete the second call. It is my mistake. I apologize for this mistake and taking your time. I can now plot the grid cells with map on it. Yet, the problem actually still persists. I can plot both map grid outlines and MPAS grid cells if I zoom in very close to the map. Here is the code that I change to play with map and grid cells: ; ---------- This plots both map boundaries and MPAS grid cells due to zooming in on the map at San Francisco Bay. Both of them are visible. Please see attached figure 1 ---------- res at mpMinLatF = 36 res at mpMaxLatF = 39 ; choose subregion res at mpMinLonF = -124 res at mpMaxLonF = -121 map = gsn_csm_map(wks,res) ; --------- This plots both map boundaries and MPAS grid cells. But, MPAS grid cells crowd the plot and map and grid cells are not discernible. Map boundary is just outside of California and Nevada. Please see figure 2 ----- res at mpMinLatF = 31.5 res at mpMaxLatF = 43 ; choose subregion res at mpMinLonF = -127.5 res at mpMaxLonF = -113 map = gsn_csm_map(wks,res) ; -------- This only plots MPAS grid cells. Map boundaries are not plotted. Map boundary is slightly bigger than the domain covering in Figure 2. Please see figure 3-------- res at mpMinLatF = 30 res at mpMaxLatF = 35 res at mpMinLonF = -130 res at mpMaxLonF = -125 ; ------------------------------------------ Kemal. From: Rick Brownrigg > Sent: Thursday, September 15, 2022 1:38 PM To: Gurer, Kemal at ARB > Cc: ncl-talk at ucar.edu forum > Subject: Re: [ncl-talk] draw order issue CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. OK, In the script, as presented to us, there are two calls to gsn_csm_map. They have different lat/lon extents and they both assign the result to the variable "map" (I'm suprised there was no error/warning). In any case, the 2nd set of lat/lon extents are off the coast. That second set is what the MPAS appears to be drawing on top of. HTH... Rick On Thu, Sep 15, 2022 at 1:56 PM Gurer, Kemal at ARB > wrote: Hi Rick, I tried that before. It didn't help. That is, MPAS grid cells are still plotted without map outlines. Kemal. From: Rick Brownrigg > Sent: Thursday, September 15, 2022 12:39 PM To: Gurer, Kemal at ARB > Cc: ncl-talk at ucar.edu forum > Subject: Re: [ncl-talk] draw order issue CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. Hi Kemal, What does the plot look like when you try to plot both map and lines together? Have you tried without the mpOutlineDrawOrder resource? Rick On Thu, Sep 15, 2022 at 1:22 PM Gurer, Kemal at ARB via ncl-talk > wrote: Hello ncl'ers, I am trying to plot MPAS grid cells on the top of US map using ncl. I attached the script that plots map and outlines. I can draw maps and MPAS grid cells separately, but I cannot plot map outline on the top of MPAS grid cells even though I set the draw order to "PostDraw". Could you help me to identify what I am doing wrong? Thanks, Kemal. _______________________________________________ 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: From barry.h.lynn at gmail.com Thu Sep 22 11:28:15 2022 From: barry.h.lynn at gmail.com (Barry Lynn) Date: Thu, 22 Sep 2022 20:28:15 +0300 Subject: [ncl-talk] Plotting Composite radar data -- how to? Message-ID: Hello: I am wondering if there is a simple way to plot this radar data correctly on a grid. I can extract the radar data, no problem, but am wondering how to specify the lat/lon of the data. Can it be obtained from the radar data itself? Thank you. Variable: b Type: file filename: 20120415-080000 path: 20120415-080000.netcdf file global attributes: TypeName : mrefl_mosaic DataType : LatLonHeightGrid Time : 1334476800 FractionalTime : 0 MissingData : -999 RangeFolded : -1000 Latitude : 40 Longitude : -110 Height : 500 LatGridSpacing : 0.01 LonGridSpacing : 0.01 attributes : dimensions: Ht = 31 Lat = 2001 Lon = 2001 variables: short mrefl_mosaic ( Ht, Lat, Lon ) Units : dBZ Scale : 10 float Height ( Ht ) Units : Meters -- Barry H. Lynn, Ph.D Senior Scientist, Lecturer, The Institute of Earth Sciences, The Hebrew University of Jerusalem, Givat Ram, Jerusalem 91904, Israel Tel: 972 547 231 170 Fax: (972)-25662581 Weather It Is, LTD Weather and Climate Focus https://weather-it-is.com Jerusalem, Israel Local: 02 930 9525 Cell: 054 7 231 170 Int-IS: x972 2 930 9525 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.allured at noaa.gov Thu Sep 22 13:30:09 2022 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Thu, 22 Sep 2022 13:30:09 -0600 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Hello: > > I am wondering if there is a simple way to plot this radar data > correctly on a grid. > > I can extract the radar data, no problem, but am wondering how to specify > the lat/lon of the data. Can it be obtained from the radar data itself? > > Thank you. > > Variable: b > > Type: file > > filename: 20120415-080000 > > path: 20120415-080000.netcdf > > file global attributes: > > TypeName : mrefl_mosaic > > DataType : LatLonHeightGrid > > Time : 1334476800 > > FractionalTime : 0 > > MissingData : -999 > > RangeFolded : -1000 > > Latitude : 40 > > Longitude : -110 > > Height : 500 > > LatGridSpacing : 0.01 > > LonGridSpacing : 0.01 > > attributes : > > dimensions: > > Ht = 31 > > Lat = 2001 > > Lon = 2001 > > variables: > > short mrefl_mosaic ( Ht, Lat, Lon ) > > Units : dBZ > > Scale : 10 > > > float Height ( Ht ) > > Units : Meters > > -- > > Barry H. Lynn, Ph.D > Senior Scientist, Lecturer, > The Institute of Earth Sciences, > The Hebrew University of Jerusalem, > Givat Ram, Jerusalem 91904, Israel > Tel: 972 547 231 170 > Fax: (972)-25662581 > > Weather It Is, LTD > Weather and Climate Focus > https://weather-it-is.com > Jerusalem, Israel > Local: 02 930 9525 > Cell: 054 7 231 170 > Int-IS: x972 2 930 9525 > > _______________________________________________ > 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: From barry.h.lynn at gmail.com Thu Sep 22 13:53:23 2022 From: barry.h.lynn at gmail.com (Barry Lynn) Date: Thu, 22 Sep 2022 22:53:23 +0300 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: Hi: Did you mean to answer? On Thu, 22 Sep 2022 at 22:30 Dave Allured - NOAA Affiliate < dave.allured at noaa.gov> wrote: > > > On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Hello: >> >> I am wondering if there is a simple way to plot this radar data >> correctly on a grid. >> >> I can extract the radar data, no problem, but am wondering how to specify >> the lat/lon of the data. Can it be obtained from the radar data itself? >> >> Thank you. >> >> Variable: b >> >> Type: file >> >> filename: 20120415-080000 >> >> path: 20120415-080000.netcdf >> >> file global attributes: >> >> TypeName : mrefl_mosaic >> >> DataType : LatLonHeightGrid >> >> Time : 1334476800 >> >> FractionalTime : 0 >> >> MissingData : -999 >> >> RangeFolded : -1000 >> >> Latitude : 40 >> >> Longitude : -110 >> >> Height : 500 >> >> LatGridSpacing : 0.01 >> >> LonGridSpacing : 0.01 >> >> attributes : >> >> dimensions: >> >> Ht = 31 >> >> Lat = 2001 >> >> Lon = 2001 >> >> variables: >> >> short mrefl_mosaic ( Ht, Lat, Lon ) >> >> Units : dBZ >> >> Scale : 10 >> >> >> float Height ( Ht ) >> >> Units : Meters >> >> -- >> >> Barry H. Lynn, Ph.D >> Senior Scientist, Lecturer, >> The Institute of Earth Sciences, >> The Hebrew University of Jerusalem, >> Givat Ram, Jerusalem 91904, Israel >> Tel: 972 547 231 170 >> Fax: (972)-25662581 >> >> Weather It Is, LTD >> Weather and Climate Focus >> https://weather-it-is.com >> Jerusalem, Israel >> Local: 02 930 9525 >> Cell: 054 7 231 170 >> Int-IS: x972 2 930 9525 >> >> _______________________________________________ >> ncl-talk mailing list >> ncl-talk at mailman.ucar.edu >> List instructions, subscriber options, unsubscribe: >> https://mailman.ucar.edu/mailman/listinfo/ncl-talk >> > -- Barry H. Lynn, Ph.D Senior Scientist, Lecturer, The Institute of Earth Sciences, The Hebrew University of Jerusalem, Givat Ram, Jerusalem 91904, Israel Tel: 972 547 231 170 Fax: (972)-25662581 Weather It Is, LTD Weather and Climate Focus https://weather-it-is.com Jerusalem, Israel Local: 02 930 9525 Cell: 054 7 231 170 Int-IS: x972 2 930 9525 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.allured at noaa.gov Thu Sep 22 13:53:36 2022 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Thu, 22 Sep 2022 13:53:36 -0600 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: Barry, this file lacks the coordinate variables that are normally provided in most published Netcdf data sets. However, there appears to be almost enough information in the global attributes to construct grid coordinates. There are reference latitude and longitude, and the X and Y grid spacing. The reference coordinates are ambiguous. My guess is they are probably grid center coordinates, but not sure. With odd numbers for both X and Y dimensions, that suggests that the center grid point (1000, 1000) is right at (40N, 110W). So just calculate X and Y coordinate vectors centered on the reference coordinates, attach them to the data variable, then plot normally. To minimize precision loss, use *ispan* and divide by 100 as the final step, because 0.01 step size is not exactly representable in floating point. (Not very important.) E.g.: lats = lat_center + (double (ispan (-1000, 1000, 1)) / 100) lons = lon_center + (double (ispan (-1000, 1000, 1)) / 100) On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Hello: > > I am wondering if there is a simple way to plot this radar data > correctly on a grid. > > I can extract the radar data, no problem, but am wondering how to specify > the lat/lon of the data. Can it be obtained from the radar data itself? > > Thank you. > > Variable: b > > Type: file > > filename: 20120415-080000 > > path: 20120415-080000.netcdf > > file global attributes: > > TypeName : mrefl_mosaic > > DataType : LatLonHeightGrid > > Time : 1334476800 > > FractionalTime : 0 > > MissingData : -999 > > RangeFolded : -1000 > > Latitude : 40 > > Longitude : -110 > > Height : 500 > > LatGridSpacing : 0.01 > > LonGridSpacing : 0.01 > > attributes : > > dimensions: > > Ht = 31 > > Lat = 2001 > > Lon = 2001 > > variables: > > short mrefl_mosaic ( Ht, Lat, Lon ) > > Units : dBZ > > Scale : 10 > > > float Height ( Ht ) > > Units : Meters > -- > Barry H. Lynn, Ph.D > Senior Scientist, Lecturer, > The Institute of Earth Sciences, > The Hebrew University of Jerusalem, > Givat Ram, Jerusalem 91904, Israel > Tel: 972 547 231 170 > Fax: (972)-25662581 > > Weather It Is, LTD > Weather and Climate Focus > https://weather-it-is.com > Jerusalem, Israel > Local: 02 930 9525 > Cell: 054 7 231 170 > Int-IS: x972 2 930 9525 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shea at ucar.edu Thu Sep 22 14:58:36 2022 From: shea at ucar.edu (Dennis Shea) Date: Thu, 22 Sep 2022 14:58:36 -0600 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: f = addfile(..., "r") xs = f->mrefl_mosaic xs at _FillValue = toshort(f at MissingData) ; MissingData is not standard xf = short2flt( xs ) delete(xs) printVarSummary(cf) printMinMax(xf) As noted by DaveA ; add coordinate info === Latitude : 40 Longitude : -110 Height : 500 LatGridSpacing : 0.01 LonGridSpacing : 0.01 On Thu, Sep 22, 2022 at 1:54 PM Dave Allured - NOAA Affiliate via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Barry, this file lacks the coordinate variables that are normally provided > in most published Netcdf data sets. However, there appears to be almost > enough information in the global attributes to construct grid coordinates. > There are reference latitude and longitude, and the X and Y grid spacing. > > The reference coordinates are ambiguous. My guess is they are probably > grid center coordinates, but not sure. With odd numbers for both X and Y > dimensions, that suggests that the center grid point (1000, 1000) is right > at (40N, 110W). > > So just calculate X and Y coordinate vectors centered on the reference > coordinates, attach them to the data variable, then plot normally. To > minimize precision loss, use *ispan* and divide by 100 as the final step, > because 0.01 step size is not exactly representable in floating point. > (Not very important.) E.g.: > > lats = lat_center + (double (ispan (-1000, 1000, 1)) / 100) > lons = lon_center + (double (ispan (-1000, 1000, 1)) / 100) > > > On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Hello: >> >> I am wondering if there is a simple way to plot this radar data >> correctly on a grid. >> >> I can extract the radar data, no problem, but am wondering how to specify >> the lat/lon of the data. Can it be obtained from the radar data itself? >> >> Thank you. >> >> Variable: b >> >> Type: file >> >> filename: 20120415-080000 >> >> path: 20120415-080000.netcdf >> >> file global attributes: >> >> TypeName : mrefl_mosaic >> >> DataType : LatLonHeightGrid >> >> Time : 1334476800 >> >> FractionalTime : 0 >> >> MissingData : -999 >> >> RangeFolded : -1000 >> >> Latitude : 40 >> >> Longitude : -110 >> >> Height : 500 >> >> LatGridSpacing : 0.01 >> >> LonGridSpacing : 0.01 >> >> attributes : >> >> dimensions: >> >> Ht = 31 >> >> Lat = 2001 >> >> Lon = 2001 >> >> variables: >> >> short mrefl_mosaic ( Ht, Lat, Lon ) >> >> Units : dBZ >> >> Scale : 10 >> >> >> float Height ( Ht ) >> >> Units : Meters >> -- >> Barry H. Lynn, Ph.D >> Senior Scientist, Lecturer, >> The Institute of Earth Sciences, >> The Hebrew University of Jerusalem, >> Givat Ram, Jerusalem 91904, Israel >> Tel: 972 547 231 170 >> Fax: (972)-25662581 >> >> Weather It Is, LTD >> Weather and Climate Focus >> https://weather-it-is.com >> Jerusalem, Israel >> Local: 02 930 9525 >> Cell: 054 7 231 170 >> Int-IS: x972 2 930 9525 >> > _______________________________________________ > 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: From dave.allured at noaa.gov Thu Sep 22 15:00:51 2022 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Thu, 22 Sep 2022 15:00:51 -0600 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: Oops. The center grid point is at (1001, 1001), not (1000, 1000). But those offset formulas are correct as shown. On Thu, Sep 22, 2022 at 1:53 PM Dave Allured - NOAA Affiliate < dave.allured at noaa.gov> wrote: > Barry, this file lacks the coordinate variables that are normally provided > in most published Netcdf data sets. However, there appears to be almost > enough information in the global attributes to construct grid coordinates. > There are reference latitude and longitude, and the X and Y grid spacing. > > The reference coordinates are ambiguous. My guess is they are probably > grid center coordinates, but not sure. With odd numbers for both X and Y > dimensions, that suggests that the center grid point (1000, 1000) is right > at (40N, 110W). > > So just calculate X and Y coordinate vectors centered on the reference > coordinates, attach them to the data variable, then plot normally. To > minimize precision loss, use *ispan* and divide by 100 as the final step, > because 0.01 step size is not exactly representable in floating point. > (Not very important.) E.g.: > > lats = lat_center + (double (ispan (-1000, 1000, 1)) / 100) > lons = lon_center + (double (ispan (-1000, 1000, 1)) / 100) > > > On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Hello: >> >> I am wondering if there is a simple way to plot this radar data >> correctly on a grid. >> >> I can extract the radar data, no problem, but am wondering how to specify >> the lat/lon of the data. Can it be obtained from the radar data itself? >> >> Thank you. >> >> Variable: b >> >> Type: file >> >> filename: 20120415-080000 >> >> path: 20120415-080000.netcdf >> >> file global attributes: >> >> TypeName : mrefl_mosaic >> >> DataType : LatLonHeightGrid >> >> Time : 1334476800 >> >> FractionalTime : 0 >> >> MissingData : -999 >> >> RangeFolded : -1000 >> >> Latitude : 40 >> >> Longitude : -110 >> >> Height : 500 >> >> LatGridSpacing : 0.01 >> >> LonGridSpacing : 0.01 >> >> attributes : >> >> dimensions: >> >> Ht = 31 >> >> Lat = 2001 >> >> Lon = 2001 >> >> variables: >> >> short mrefl_mosaic ( Ht, Lat, Lon ) >> >> Units : dBZ >> >> Scale : 10 >> >> >> float Height ( Ht ) >> >> Units : Meters >> -- >> Barry H. Lynn, Ph.D >> Senior Scientist, Lecturer, >> The Institute of Earth Sciences, >> The Hebrew University of Jerusalem, >> Givat Ram, Jerusalem 91904, Israel >> Tel: 972 547 231 170 >> Fax: (972)-25662581 >> >> Weather It Is, LTD >> Weather and Climate Focus >> https://weather-it-is.com >> Jerusalem, Israel >> Local: 02 930 9525 >> Cell: 054 7 231 170 >> Int-IS: x972 2 930 9525 >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From barry.h.lynn at gmail.com Fri Sep 23 08:16:57 2022 From: barry.h.lynn at gmail.com (Barry Lynn) Date: Fri, 23 Sep 2022 17:16:57 +0300 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: Hi: That was very helpful, thank you. I can now read the data and create lat/lon coordinates. I am still left with one error, though, which is quite vexing.* I need to give the radar variable coordinate *information so I can map it. The typical warning is shown in the last set of yellowed lines, The code reads as immediately below, and the error when I try to run it by adding coordinate variable information is specified in the last of the second set of yellowed lines, bolded). CODE! filename_b="20120415-080000.netcdf" b = addfile(filename_b,"r") print(b) xs = b->mrefl_mosaic xs at _FillValue = toshort(b at MissingData) ; MissingData is not standard xf = short2flt( xs ) delete(xs) printVarSummary(xf) printMinMax(xf,False) radar = xf(5,:,:) printVarSummary(radar) lat_center = 40 lon_center = -110 lats = lat_center + todouble(ispan(-1000, 1000, 1)/100) lons = lon_center + todouble(ispan(-1000, 1000, 1)/100) *res = True* * res&lats at units = "degrees_north" ; GIVES "compilation" ERROR (Specified BELOW)* * res&lons at units = "degrees_east"* Here's the compilation error (bolded below). Variable: radar Type: float Total Size: 16016004 bytes 4004001 values Number of Dimensions: 2 Dimensions and sizes: [Lat | 2001] x [Lon | 2001] Coordinates: Number Of Attributes: 3 _FillValue : -999 _FillValue_original : -999 Units : dBZ *fatal:(lats) is not a named dimension in variable (res).* *fatal:["Execute.c":8575]:Execute: Error occurred at or near line 44 in file ./obs_radar.ncl* Without this coordinate information, I get: *fatal:(lats) is not a named dimension in variable (res).* (0) check_for_y_lat_coord: Warning: Data either does not contain a valid latitude coordinate array or doesn't contain one at all. (0) A valid latitude coordinate array should have a 'units' 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) check_for_lon_coord: Warning: Data either does not contain a valid longitude coordinate array or doesn't contain one at all. (0) A valid longitude coordinate array should have a 'units' attribute equal to one of the following values: On Fri, Sep 23, 2022 at 12:01 AM Dave Allured - NOAA Affiliate < dave.allured at noaa.gov> wrote: > Oops. The center grid point is at (1001, 1001), not (1000, 1000). But > those offset formulas are correct as shown. > > > On Thu, Sep 22, 2022 at 1:53 PM Dave Allured - NOAA Affiliate < > dave.allured at noaa.gov> wrote: > >> Barry, this file lacks the coordinate variables that are normally >> provided in most published Netcdf data sets. However, there appears to be >> almost enough information in the global attributes to construct grid >> coordinates. There are reference latitude and longitude, and the X and Y >> grid spacing. >> >> The reference coordinates are ambiguous. My guess is they are probably >> grid center coordinates, but not sure. With odd numbers for both X and Y >> dimensions, that suggests that the center grid point (1000, 1000) is right >> at (40N, 110W). >> >> So just calculate X and Y coordinate vectors centered on the reference >> coordinates, attach them to the data variable, then plot normally. To >> minimize precision loss, use *ispan* and divide by 100 as the final >> step, because 0.01 step size is not exactly representable in floating >> point. (Not very important.) E.g.: >> >> lats = lat_center + (double (ispan (-1000, 1000, 1)) / 100) >> lons = lon_center + (double (ispan (-1000, 1000, 1)) / 100) >> >> >> On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < >> ncl-talk at mailman.ucar.edu> wrote: >> >>> Hello: >>> >>> I am wondering if there is a simple way to plot this radar data >>> correctly on a grid. >>> >>> I can extract the radar data, no problem, but am wondering how to >>> specify the lat/lon of the data. Can it be obtained from the radar data >>> itself? >>> >>> Thank you. >>> >>> Variable: b >>> >>> Type: file >>> >>> filename: 20120415-080000 >>> >>> path: 20120415-080000.netcdf >>> >>> file global attributes: >>> >>> TypeName : mrefl_mosaic >>> >>> DataType : LatLonHeightGrid >>> >>> Time : 1334476800 >>> >>> FractionalTime : 0 >>> >>> MissingData : -999 >>> >>> RangeFolded : -1000 >>> >>> Latitude : 40 >>> >>> Longitude : -110 >>> >>> Height : 500 >>> >>> LatGridSpacing : 0.01 >>> >>> LonGridSpacing : 0.01 >>> >>> attributes : >>> >>> dimensions: >>> >>> Ht = 31 >>> >>> Lat = 2001 >>> >>> Lon = 2001 >>> >>> variables: >>> >>> short mrefl_mosaic ( Ht, Lat, Lon ) >>> >>> Units : dBZ >>> >>> Scale : 10 >>> >>> >>> float Height ( Ht ) >>> >>> Units : Meters >>> -- >>> Barry H. Lynn, Ph.D >>> Senior Scientist, Lecturer, >>> The Institute of Earth Sciences, >>> The Hebrew University of Jerusalem, >>> Givat Ram, Jerusalem 91904, Israel >>> Tel: 972 547 231 170 >>> Fax: (972)-25662581 >>> >>> Weather It Is, LTD >>> Weather and Climate Focus >>> https://weather-it-is.com >>> Jerusalem, Israel >>> Local: 02 930 9525 >>> Cell: 054 7 231 170 >>> Int-IS: x972 2 930 9525 >>> >> -- Barry H. Lynn, Ph.D Senior Scientist, Lecturer, The Institute of Earth Sciences, The Hebrew University of Jerusalem, Givat Ram, Jerusalem 91904, Israel Tel: 972 547 231 170 Fax: (972)-25662581 Weather It Is, LTD Weather and Climate Focus https://weather-it-is.com Jerusalem, Israel Local: 02 930 9525 Cell: 054 7 231 170 Int-IS: x972 2 930 9525 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.allured at noaa.gov Fri Sep 23 08:44:25 2022 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Fri, 23 Sep 2022 08:44:25 -0600 Subject: [ncl-talk] Plotting Composite radar data -- how to? In-Reply-To: References: Message-ID: Barry, in NCL, 1-D coordinate variables are attached to the data variable, not the plot resource. Also, the coordinate variable name must be an exact match with the associated dimension name. https://www.ncl.ucar.edu/Document/Language/cv.shtml There is more than one way to do this. I prefer to fix up the coordinate variables independently, before attaching them to the data variable. I also suggest attaching early, before subsetting, in case you want to extract other subsets later. You could just as easily attach directly to "radar". Try this, untested: lats at units = "degrees_north" lons at units = "degrees_east" lats!0 = "Lat" ; assign dim names to avoid warning lons!0 = "Lon" xf&Lat = lats ; attach to data var xf&Lon = lons radar = xf(5,:,:) ; attached coords will be copied On Fri, Sep 23, 2022 at 8:17 AM Barry Lynn wrote: > Hi: > > That was very helpful, thank you. I can now read the data and create > lat/lon coordinates. > > I am still left with one error, though, which is quite vexing.* I need > to give the radar variable coordinate *information so I can map it. The > typical warning is shown in the last set of yellowed lines, > > The code reads as immediately below, and the error when I try to run it by > adding coordinate variable information is specified in the last of the > second set of yellowed lines, bolded). > > CODE! > > filename_b="20120415-080000.netcdf" > > b = addfile(filename_b,"r") > > print(b) > > xs = b->mrefl_mosaic > > xs at _FillValue = toshort(b at MissingData) ; MissingData is not standard > > xf = short2flt( xs ) > > delete(xs) > > printVarSummary(xf) > > printMinMax(xf,False) > > radar = xf(5,:,:) > > printVarSummary(radar) > > lat_center = 40 > > lon_center = -110 > > lats = lat_center + todouble(ispan(-1000, 1000, 1)/100) > > lons = lon_center + todouble(ispan(-1000, 1000, 1)/100) > > *res = True* > > * res&lats at units = "degrees_north" ; GIVES "compilation" ERROR > (Specified BELOW)* > > * res&lons at units = "degrees_east"* > > Here's the compilation error (bolded below). > > Variable: radar > > Type: float > > Total Size: 16016004 bytes > > 4004001 values > > Number of Dimensions: 2 > > Dimensions and sizes: [Lat | 2001] x [Lon | 2001] > > Coordinates: > > Number Of Attributes: 3 > > _FillValue : -999 > > _FillValue_original : -999 > > Units : dBZ > > *fatal:(lats) is not a named dimension in variable (res).* > > *fatal:["Execute.c":8575]:Execute: Error occurred at or near line 44 in > file ./obs_radar.ncl* > > Without this coordinate information, I get: > > > *fatal:(lats) is not a named dimension in variable (res).* > > (0) check_for_y_lat_coord: Warning: Data either does not contain a valid > latitude coordinate array or doesn't contain one at all. > > (0) A valid latitude coordinate array should have a 'units' 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) check_for_lon_coord: Warning: Data either does not contain a valid > longitude coordinate array or doesn't contain one at all. > > (0) A valid longitude coordinate array should have a 'units' attribute > equal to one of the following values: > > > On Fri, Sep 23, 2022 at 12:01 AM Dave Allured - NOAA Affiliate < > dave.allured at noaa.gov> wrote: > >> Oops. The center grid point is at (1001, 1001), not (1000, 1000). But >> those offset formulas are correct as shown. >> >> >> On Thu, Sep 22, 2022 at 1:53 PM Dave Allured - NOAA Affiliate < >> dave.allured at noaa.gov> wrote: >> >>> Barry, this file lacks the coordinate variables that are normally >>> provided in most published Netcdf data sets. However, there appears to be >>> almost enough information in the global attributes to construct grid >>> coordinates. There are reference latitude and longitude, and the X and Y >>> grid spacing. >>> >>> The reference coordinates are ambiguous. My guess is they are probably >>> grid center coordinates, but not sure. With odd numbers for both X and Y >>> dimensions, that suggests that the center grid point (1000, 1000) is right >>> at (40N, 110W). >>> >>> So just calculate X and Y coordinate vectors centered on the reference >>> coordinates, attach them to the data variable, then plot normally. To >>> minimize precision loss, use *ispan* and divide by 100 as the final >>> step, because 0.01 step size is not exactly representable in floating >>> point. (Not very important.) E.g.: >>> >>> lats = lat_center + (double (ispan (-1000, 1000, 1)) / 100) >>> lons = lon_center + (double (ispan (-1000, 1000, 1)) / 100) >>> >>> >>> On Thu, Sep 22, 2022 at 11:28 AM Barry Lynn via ncl-talk < >>> ncl-talk at mailman.ucar.edu> wrote: >>> >>>> Hello: >>>> >>>> I am wondering if there is a simple way to plot this radar data >>>> correctly on a grid. >>>> >>>> I can extract the radar data, no problem, but am wondering how to >>>> specify the lat/lon of the data. Can it be obtained from the radar data >>>> itself? >>>> >>>> Thank you. >>>> >>>> Variable: b >>>> >>>> Type: file >>>> >>>> filename: 20120415-080000 >>>> >>>> path: 20120415-080000.netcdf >>>> >>>> file global attributes: >>>> >>>> TypeName : mrefl_mosaic >>>> >>>> DataType : LatLonHeightGrid >>>> >>>> Time : 1334476800 >>>> >>>> FractionalTime : 0 >>>> >>>> MissingData : -999 >>>> >>>> RangeFolded : -1000 >>>> >>>> Latitude : 40 >>>> >>>> Longitude : -110 >>>> >>>> Height : 500 >>>> >>>> LatGridSpacing : 0.01 >>>> >>>> LonGridSpacing : 0.01 >>>> >>>> attributes : >>>> >>>> dimensions: >>>> >>>> Ht = 31 >>>> >>>> Lat = 2001 >>>> >>>> Lon = 2001 >>>> >>>> variables: >>>> >>>> short mrefl_mosaic ( Ht, Lat, Lon ) >>>> >>>> Units : dBZ >>>> >>>> Scale : 10 >>>> >>>> >>>> float Height ( Ht ) >>>> >>>> Units : Meters >>>> -- >>>> Barry H. Lynn, Ph.D >>>> Senior Scientist, Lecturer, >>>> The Institute of Earth Sciences, >>>> The Hebrew University of Jerusalem, >>>> Givat Ram, Jerusalem 91904, Israel >>>> Tel: 972 547 231 170 >>>> Fax: (972)-25662581 >>>> >>>> Weather It Is, LTD >>>> Weather and Climate Focus >>>> https://weather-it-is.com >>>> Jerusalem, Israel >>>> Local: 02 930 9525 >>>> Cell: 054 7 231 170 >>>> Int-IS: x972 2 930 9525 >>>> >>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From M.Lazenby at sussex.ac.uk Wed Sep 28 08:45:05 2022 From: M.Lazenby at sussex.ac.uk (Melissa Lazenby) Date: Wed, 28 Sep 2022 14:45:05 +0000 Subject: [ncl-talk] Issue with Decimal Places and Rounding off Message-ID: Hi NCL Users I am currently using the function decimalPlaces like this below: Round = decimalPlaces(rcMaxLon,2,True) Round1 = decimalPlaces(rcMaxLon at yave,2,True) pr4 at long_name = ""+model(gg)+"" pr4 at units = "s="+Round+" lat="+Round1+"" However, when I plot up my 39 CMIP models there are 3 in which the rounding to 2 decimal places has not worked properly...any ideas why this would be and any suggestions to fix it will be highly appreciated. [cid:12776569-4ae3-473e-8535-21eef4fc0956] [cid:dbfe906c-9598-431d-b6de-970a9e9b1607] Kindest Regards Melissa Full code below: ;************************************************* ; regline_panel plots.ncl ; ;************************************************* load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" begin ;************************************************ ; Read in Precip Data. ;************************************************ ;Models model = (/"ACCESS1-0","ACCESS1-3","bcc-csm1-1","BNU-ESM","CanESM2","CCSM4","CESM1-BGC","CESM1-CAM5","CMCC-CM","CMCC-CMS","CNRM-CM5","CSIRO-Mk3-6-0","EC-EARTH","FGOALS-g2","FIO-ESM","GFDL-CM3","GFDL-ESM2G","GFDL-ESM2M","GISS-E2-H_p1","GISS-E2-H_p2","GISS-E2-H_p3","GISS-E2-R_p1","GISS-E2-R_p2","GISS-E2-R_p3","HadGEM2-AO","HadGEM2-CC","HadGEM2-ES","inmcm4","IPSL-CM5A-LR","IPSL-CM5A-MR","IPSL-CM5B-LR","MIROC5","MIROC-ESM","MIROC-ESM-CHEM","MPI-ESM-LR","MPI-ESM-MR","MRI-CGCM3","NorESM1-M","NorESM1-ME"/) wks = gsn_open_wks("X11","2022_PHD_IPCC_Model_regline_historical_overlay_1981-2010_25-50") ; specifies a plot gsn_define_colormap(wks,"BlueOrangeRed") ; choose color map gsn_reverse_colormap(wks) plot = new (dimsizes(model),"graphic") do gg = 0,dimsizes(model)-1 in=addfile("/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/historicalregline1981_2010IPCC/pr_Amon_"+model(gg)+"_historical_safrica_climDJF2022.nc","r") lat = in->lat ; get lat lon = in->lon ; get lon time = in->time ; get time pr1 = in->pr(:,:,:) pr2 = pr1(time|0, {lat|-30:0}, {lon|25:50}) dimpr2 = dimsizes(pr2) nlat = dimpr2(0) mlon = dimpr2(1) pr2MaxLon = new ( mlon, typeof(pr2), pr2 at _FillValue) do ml=0,mlon-1 imax = maxind(pr2(:,ml)) pr2MaxLon(ml) = dble2flt(lat(imax)) end do print(pr2MaxLon) print(pr2&lon) print("-------------------------------") print("pr2MaxLon: "+pr2&lon+" "+pr2MaxLon) ;Regression Line rcMaxLon = regline(pr2&lon,pr2MaxLon) print(rcMaxLon) print(rcMaxLon at yave) bMaxLon = rcMaxLon at yintercept print(bMaxLon) xMaxLon = pr2&lon print(xMaxLon) yMaxLon = rcMaxLon*pr2&lon + bMaxLon print(yMaxLon) print("-------------------------------") print(xMaxLon+" "+yMaxLon) ;************************************************ ; create an array to hold both the original data ; and the calculated regression line ;************************************************ data = new ( (/2,dimsizes(pr2MaxLon)/), typeof(pr2MaxLon)) data(1,:) = dble2flt(rcMaxLon)*(dble2flt(xMaxLon)-dble2flt(rcMaxLon at xave)) + dble2flt(rcMaxLon at yave) ;************************************************ ; Read in Precip Data with larger domain. ;************************************************ f=addfile("/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/historicalregline1981_2010largeIPCC/pr_Amon_"+model(gg)+"_historical_safrica_climDJF2022.nc","r") lat1 = f->lat ; get lat lon1 = f->lon ; get lon time1 = f->time pr6 = f->pr(:,:,:) pr4 = pr6(time|0,{lat|-40:10}, {lon|-10:70}) ;************************************************ ; Read in Precip Data. ;************************************************ ;Obs cin = addfile("/mnt/geog/ml382/melphd/regressionline/SIOCZ/pr_CMAP_historical_safrica_climDJF_small.nc","r") prcmap = cin->precip(:,:,:) pr5 = prcmap(time|0, {lat|-30:0}, {lon|25:50}) ;************************************************************* ;Calculations of max precip for lat and lon values observations (CMAP) ;************************************************************** dimpr5 = dimsizes(pr5) nlat = dimpr5(0) mlon = dimpr5(1) pr5MaxLon = new ( mlon, typeof(pr5), pr5 at _FillValue) do ml=0,mlon-1 imax = maxind(pr5(:,ml)) pr5MaxLon(ml) = dble2flt(lat(imax)) end do print(pr5MaxLon) print(pr5&lon) print("-------------------------------") print("pr5MaxLon: "+pr5&lon+" "+pr5MaxLon) ;Regression Line regcMaxLon = regline(pr5&lon,pr5MaxLon) print(regcMaxLon) print(regcMaxLon at yave) bMaxLon = regcMaxLon at yintercept print(bMaxLon) xMaxLon = pr5&lon print(xMaxLon) yMaxLon = regcMaxLon*pr5&lon + bMaxLon print(yMaxLon) print("-------------------------------") print(xMaxLon+" "+yMaxLon) ;************************************************ ; create an array to hold both the original data ; and the calculated regression line ;************************************************ datac = new ( (/2,dimsizes(pr5MaxLon)/), typeof(pr5MaxLon)) datac(1,:) = dble2flt(regcMaxLon)*(dble2flt(xMaxLon)-dble2flt(regcMaxLon at xave)) + dble2flt(regcMaxLon at yave) ; resource lists res = True ; plot mods desired res at gsnAddCyclic = False res at cnFillOn = True ; color on res at lbLabelStride = 2 ; every other label res at gsnSpreadColors = True ; use full range of color map res at cnLineLabelsOn = False ; no contour line labels res at lbLabelBarOn = False res at gsnDraw = False ; do not draw the plot res at gsnFrame = False ;pr4 = pr6(0,{-40:10},{-10:70}) dimpr4 = dimsizes(pr4) latn = dimpr4(0) lonm = dimpr4(1) res at mpLimitMode = "Corners" ; res at mpLeftCornerLonF = lon1(0) res at mpRightCornerLonF = lon1(lonm-1) res at mpLeftCornerLatF = lat1(0) res at mpRightCornerLatF = lat1(latn-1) res at tmXBMode = "Explicit" ; Define own tick mark labels. res at tmXBValues = (/ -9.,0.,10.,20.,30.,40.,50.,60.,69 /) res at tmXBLabels = (/ "10W","0","10E","20E","30E","40E","50E","60E","70E" /) res at tmYLMode = "Explicit" ; Define own tick mark labels. res at tmYLValues = (/ -39.,-30.,-20.,-10.,-0.,9 /) res at tmYLLabels = (/"40S","30S","20S","10S","0","10N" /) res at vpXF = 0.12 ; default is 0.2 change aspect res at vpYF = 0.8 ; default is 0.8 ration res at vpHeightF = 0.4 ; default is 0.6 res at vpWidthF = 0.8 ; default is 0.6 res at cnLevelSelectionMode = "ManualLevels" ; manual levels res at cnMinLevelValF = 0 ; min level res at cnMaxLevelValF = 400 ; max level res at cnLevelSpacingF = 50 ; contour spacing res at tmXBLabelFontHeightF = 0.022 ; resize tick labels res at tmYLLabelFontHeightF = 0.022 res at pmLabelBarOrthogonalPosF = .25 ; move whole thing down ;************************************************ ; plotting parameters ;************************************************ sres = True ; plot mods desired sres at gsnMaximize = True ; maximize plot in frame sres at xyMarkLineModes = (/"Markers","Lines"/) ; choose which have markers sres at xyMarkers = 16 ; choose type of marker sres at xyLineColors = (/"blue","black"/) sres at xyMonoDashPattern = True sres at gsnLineDashPattern = 1 sres at xyDashPattern = 16 ; solid line sres at xyLineThicknesses = (/1,3/) ; set second line to 2 sres at gsnDraw = False ; do not draw the plot sres at gsnFrame = False ; reverse the first two colors setvalues wks "wkColorMap" : "BlueOrangeRed" ;"BkBlAqGrYeOrReViWh200" "wkForegroundColor" : (/0.,0.,0./) "wkBackgroundColor" : (/1.,1.,1./) end setvalues ;************************************************ ; plotting parameters ;************************************************ cres = True ; plot mods desired cres at gsnMaximize = True ; maximize plot in frame cres at xyMarkLineModes = "Lines" ; choose which have markers cres at xyDashPatterns = 0 ; solid line cres at xyLineThicknesses = (/1,3/) ; set second line to 2 cres at gsnDraw = False ; do not draw the plot cres at gsnFrame = False ; reverse the first two colors setvalues wks "wkColorMap" : "BlueOrangeRed" ;"BkBlAqGrYeOrReViWh200" "wkForegroundColor" : (/0.,0.,0./) "wkBackgroundColor" : (/1.,1.,1./) end setvalues Round = decimalPlaces(rcMaxLon,2,True) Round1 = decimalPlaces(rcMaxLon at yave,2,True) pr4 at long_name = ""+model(gg)+"" ;pr4 at units = "s="+rcMaxLon+" lat="+rcMaxLon at yave+"" pr4 at units = "s="+Round+" lat="+Round1+"" print(rcMaxLon) print(Round) print(Round1) res at tmXBLabelsOn = False ; do not draw bottom labels res at tmXBOn = False ; no bottom tickmarks res at tmYLLabelsOn = False ; no right labels res at tmYLOn = False ; no right tickmarks if((gg.eq.36) .or. (gg.eq.37) .or. (gg.eq.38)) then res at tmXBLabelsOn = True ; do not draw bottom labels res at tmXBOn = True ; no bottom tickmarks else res at tmXBLabelsOn = False ; do not draw bottom labels res at tmXBOn = False ; no bottom tickmarks end if if((gg.eq.0) .or. (gg.eq.4) .or. (gg.eq.8) .or. (gg.eq.12) .or. (gg.eq.16) .or. (gg.eq.20) .or.(gg.eq.24) .or. (gg.eq.28) .or. (gg.eq.32) .or. (gg.eq.36)) then res at tmYLLabelsOn = True ; do not draw bottom labels res at tmYLOn = True ; no bottom tickmarks else res at tmYLLabelsOn = False ; do not draw bottom labels res at tmYLOn = False ; no bottom tickmarks end if plot(gg) = gsn_csm_contour_map(wks,pr4({-40:10},{-10:70}),res) ; create plot plot2 = gsn_csm_xy(wks,pr2&lon,data,sres) ; create plot plot3 = gsn_csm_xy(wks,pr5&lon,datac,cres) ; create plot overlay(plot(gg),plot2) overlay(plot(gg),plot3) delete(pr4) end do ; panel resource list (if necessary) panres = True ; mod panel plot panres at gsnPanelLabelBar = True ; add common colorbar panres at lbLabelFontHeightF =.012 ; make labels larger panres at gsnMaximize = True ; Maximize plot in frame. gsn_panel(wks,plot(:23),(/6,4/),panres) ; panel 16 models at a time. gsn_panel(wks,plot(24:),(/6,4/),panres) ;gsn_panel(wks,plot(32:),(/4,4/),panres) ;gsn_panel(wks,plot(25:32),(/4,4/),panres) ;gsn_panel(wks,plot(33:),(/4,2/),panres) ;gsn_panel(wks,plot(41:),(/4,2/),panres) ;gsn_panel(wks,plot(::),(/4,2/),panres) end Dr. Melissa Lazenby Lecturer in Climate Change Department of Geography Chichester 1 C150 University of Sussex "Education is the most powerful weapon which you can use to change the world" Nelson Mandela [cid:32ebdb21-ea12-42a7-874a-c8cd6971e615] -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 583899 bytes Desc: image.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 378613 bytes Desc: image.png URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Outlook-yklt2iha.png Type: image/png Size: 24937 bytes Desc: Outlook-yklt2iha.png URL: From brownrig at ucar.edu Wed Sep 28 09:06:42 2022 From: brownrig at ucar.edu (Rick Brownrigg) Date: Wed, 28 Sep 2022 09:06:42 -0600 Subject: [ncl-talk] Issue with Decimal Places and Rounding off In-Reply-To: References: Message-ID: Hi Melissa, >From a quick glance at the code for decimalPlaces(), it appears that it numerically ensures there are no more than the specified number of meaningful decimal places, but it does not deal with the printing of those numbers. In fact, the docs for decimalPlaces state that for printing purposes, sprintf() might be the better choice: http://ncl.ucar.edu/Document/Functions/Built-in/sprintf.shtml Hope that helps, Rick On Wed, Sep 28, 2022 at 8:45 AM Melissa Lazenby via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Hi NCL Users > > I am currently using the function decimalPlaces like this below: > > Round = decimalPlaces(rcMaxLon,2,True) > Round1 = decimalPlaces(rcMaxLon at yave,2,True) > > pr4 at long_name = ""+model(gg)+"" > pr4 at units = "s="+Round+" lat="+Round1+"" > > However, when I plot up my 39 CMIP models there are 3 in which the > rounding to 2 decimal places has not worked properly...any ideas why this > would be and any suggestions to fix it will be highly appreciated. > > > > > > Kindest Regards > Melissa > > Full code below: > > ;************************************************* > ; regline_panel plots.ncl > ; > > ;************************************************* > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" > > begin > ;************************************************ > ; Read in Precip Data. > ;************************************************ > > ;Models > > model = > (/"ACCESS1-0","ACCESS1-3","bcc-csm1-1","BNU-ESM","CanESM2","CCSM4","CESM1-BGC","CESM1-CAM5","CMCC-CM","CMCC-CMS","CNRM-CM5","CSIRO-Mk3-6-0","EC-EARTH","FGOALS-g2","FIO-ESM","GFDL-CM3","GFDL-ESM2G","GFDL-ESM2M","GISS-E2-H_p1","GISS-E2-H_p2","GISS-E2-H_p3","GISS-E2-R_p1","GISS-E2-R_p2","GISS-E2-R_p3","HadGEM2-AO","HadGEM2-CC","HadGEM2-ES","inmcm4","IPSL-CM5A-LR","IPSL-CM5A-MR","IPSL-CM5B-LR","MIROC5","MIROC-ESM","MIROC-ESM-CHEM","MPI-ESM-LR","MPI-ESM-MR","MRI-CGCM3","NorESM1-M","NorESM1-ME"/) > > wks = > gsn_open_wks("X11","2022_PHD_IPCC_Model_regline_historical_overlay_1981-2010_25-50") > ; specifies a plot > gsn_define_colormap(wks,"BlueOrangeRed") ; choose color map > gsn_reverse_colormap(wks) > plot = new (dimsizes(model),"graphic") > do gg = 0,dimsizes(model)-1 > > in=addfile("/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/historicalregline1981_2010IPCC/pr_Amon_"+model(gg)+"_historical_safrica_climDJF2022.nc","r") > > lat = in->lat ; get lat > lon = in->lon ; get lon > time = in->time ; get time > > pr1 = in->pr(:,:,:) > > > pr2 = pr1(time|0, {lat|-30:0}, {lon|25:50}) > > dimpr2 = dimsizes(pr2) > nlat = dimpr2(0) > mlon = dimpr2(1) > > pr2MaxLon = new ( mlon, typeof(pr2), pr2 at _FillValue) > > do ml=0,mlon-1 > imax = maxind(pr2(:,ml)) > pr2MaxLon(ml) = dble2flt(lat(imax)) > end do > > print(pr2MaxLon) > print(pr2&lon) > > print("-------------------------------") > print("pr2MaxLon: "+pr2&lon+" "+pr2MaxLon) > > ;Regression Line > > rcMaxLon = regline(pr2&lon,pr2MaxLon) > print(rcMaxLon) > > print(rcMaxLon at yave) > > bMaxLon = rcMaxLon at yintercept > print(bMaxLon) > > xMaxLon = pr2&lon > print(xMaxLon) > yMaxLon = rcMaxLon*pr2&lon + bMaxLon > print(yMaxLon) > > print("-------------------------------") > print(xMaxLon+" "+yMaxLon) > > ;************************************************ > ; create an array to hold both the original data > ; and the calculated regression line > ;************************************************ > > data = new ( (/2,dimsizes(pr2MaxLon)/), typeof(pr2MaxLon)) > > data(1,:) = dble2flt(rcMaxLon)*(dble2flt(xMaxLon)-dble2flt(rcMaxLon at xave)) > + dble2flt(rcMaxLon at yave) > > ;************************************************ > ; Read in Precip Data with larger domain. > ;************************************************ > > f=addfile("/mnt/geog/ml382/ml382_sals000408_home_dir/melsicz/historicalregline1981_2010largeIPCC/pr_Amon_"+model(gg)+"_historical_safrica_climDJF2022.nc","r") > > > lat1 = f->lat ; get lat > lon1 = f->lon ; get lon > time1 = f->time > > pr6 = f->pr(:,:,:) > > pr4 = pr6(time|0,{lat|-40:10}, {lon|-10:70}) > > ;************************************************ > ; Read in Precip Data. > ;************************************************ > ;Obs > cin = > addfile("/mnt/geog/ml382/melphd/regressionline/SIOCZ/pr_CMAP_historical_safrica_climDJF_small.nc","r") > > prcmap = cin->precip(:,:,:) > pr5 = prcmap(time|0, {lat|-30:0}, {lon|25:50}) > > > ;************************************************************* > ;Calculations of max precip for lat and lon values observations (CMAP) > ;************************************************************** > > dimpr5 = dimsizes(pr5) > nlat = dimpr5(0) > mlon = dimpr5(1) > > pr5MaxLon = new ( mlon, typeof(pr5), pr5 at _FillValue) > > do ml=0,mlon-1 > imax = maxind(pr5(:,ml)) > pr5MaxLon(ml) = dble2flt(lat(imax)) > end do > > print(pr5MaxLon) > print(pr5&lon) > > print("-------------------------------") > print("pr5MaxLon: "+pr5&lon+" "+pr5MaxLon) > > ;Regression Line > > regcMaxLon = regline(pr5&lon,pr5MaxLon) > print(regcMaxLon) > > print(regcMaxLon at yave) > > bMaxLon = regcMaxLon at yintercept > print(bMaxLon) > > xMaxLon = pr5&lon > print(xMaxLon) > yMaxLon = regcMaxLon*pr5&lon + bMaxLon > print(yMaxLon) > > print("-------------------------------") > print(xMaxLon+" "+yMaxLon) > > ;************************************************ > ; create an array to hold both the original data > ; and the calculated regression line > ;************************************************ > > datac = new ( (/2,dimsizes(pr5MaxLon)/), typeof(pr5MaxLon)) > > datac(1,:) = > dble2flt(regcMaxLon)*(dble2flt(xMaxLon)-dble2flt(regcMaxLon at xave)) + > dble2flt(regcMaxLon at yave) > > > ; resource lists > > res = True ; plot mods desired > res at gsnAddCyclic = False > res at cnFillOn = True ; color on > res at lbLabelStride = 2 ; every other label > res at gsnSpreadColors = True ; use full range of color > map > res at cnLineLabelsOn = False ; no contour line labels > res at lbLabelBarOn = False > res at gsnDraw = False ; do not draw the plot > res at gsnFrame = False > > > ;pr4 = pr6(0,{-40:10},{-10:70}) > > dimpr4 = dimsizes(pr4) > latn = dimpr4(0) > lonm = dimpr4(1) > > > res at mpLimitMode = "Corners" ; > res at mpLeftCornerLonF = lon1(0) > res at mpRightCornerLonF = lon1(lonm-1) > res at mpLeftCornerLatF = lat1(0) > res at mpRightCornerLatF = lat1(latn-1) > > > res at tmXBMode = "Explicit" ; Define own tick mark labels. > res at tmXBValues = (/ -9.,0.,10.,20.,30.,40.,50.,60.,69 /) > res at tmXBLabels = (/ > "10W","0","10E","20E","30E","40E","50E","60E","70E" /) > > res at tmYLMode = "Explicit" ; Define own tick mark labels. > res at tmYLValues = (/ -39.,-30.,-20.,-10.,-0.,9 /) > res at tmYLLabels = (/"40S","30S","20S","10S","0","10N" /) > > res at vpXF = 0.12 ; default is 0.2 change aspect > res at vpYF = 0.8 ; default is 0.8 ration > res at vpHeightF = 0.4 ; default is 0.6 > res at vpWidthF = 0.8 ; default is 0.6 > > res at cnLevelSelectionMode = "ManualLevels" ; manual levels > res at cnMinLevelValF = 0 ; min level > res at cnMaxLevelValF = 400 ; max level > res at cnLevelSpacingF = 50 ; contour spacing > > res at tmXBLabelFontHeightF = 0.022 ; resize tick labels > res at tmYLLabelFontHeightF = 0.022 > res at pmLabelBarOrthogonalPosF = .25 ; move whole thing down > > > ;************************************************ > ; plotting parameters > ;************************************************ > sres = True ; plot mods desired > sres at gsnMaximize = True ; maximize plot in > frame > sres at xyMarkLineModes = (/"Markers","Lines"/) ; choose which have > markers > sres at xyMarkers = 16 ; choose type of > marker > sres at xyLineColors = (/"blue","black"/) > sres at xyMonoDashPattern = True > sres at gsnLineDashPattern = 1 > sres at xyDashPattern = 16 ; solid line > sres at xyLineThicknesses = (/1,3/) ; set second line to 2 > sres at gsnDraw = False ; do not draw the plot > sres at gsnFrame = False > > > ; reverse the first two colors > setvalues wks > "wkColorMap" : "BlueOrangeRed" ;"BkBlAqGrYeOrReViWh200" > "wkForegroundColor" : (/0.,0.,0./) > "wkBackgroundColor" : (/1.,1.,1./) > end setvalues > > ;************************************************ > ; plotting parameters > ;************************************************ > cres = True ; plot mods desired > cres at gsnMaximize = True ; maximize plot in > frame > cres at xyMarkLineModes = "Lines" ; choose which have > markers > cres at xyDashPatterns = 0 ; solid line > cres at xyLineThicknesses = (/1,3/) ; set second line to 2 > cres at gsnDraw = False ; do not draw the plot > cres at gsnFrame = False > > > ; reverse the first two colors > setvalues wks > "wkColorMap" : "BlueOrangeRed" ;"BkBlAqGrYeOrReViWh200" > "wkForegroundColor" : (/0.,0.,0./) > "wkBackgroundColor" : (/1.,1.,1./) > end setvalues > > Round = decimalPlaces(rcMaxLon,2,True) > Round1 = decimalPlaces(rcMaxLon at yave,2,True) > > pr4 at long_name = ""+model(gg)+"" > ;pr4 at units = "s="+rcMaxLon+" lat="+rcMaxLon at yave+"" > pr4 at units = "s="+Round+" lat="+Round1+"" > > > print(rcMaxLon) > print(Round) > print(Round1) > > res at tmXBLabelsOn = False ; do not draw bottom > labels > res at tmXBOn = False ; no bottom tickmarks > res at tmYLLabelsOn = False ; no right labels > res at tmYLOn = False ; no right tickmarks > > if((gg.eq.36) .or. (gg.eq.37) .or. (gg.eq.38)) then > > res at tmXBLabelsOn = True ; do not draw bottom > labels > res at tmXBOn = True ; no bottom tickmarks > else > res at tmXBLabelsOn = False ; do not draw bottom > labels > res at tmXBOn = False ; no bottom tickmarks > end if > > if((gg.eq.0) .or. (gg.eq.4) .or. (gg.eq.8) .or. (gg.eq.12) .or. > (gg.eq.16) .or. (gg.eq.20) .or.(gg.eq.24) .or. (gg.eq.28) .or. (gg.eq.32) > .or. (gg.eq.36)) then > res at tmYLLabelsOn = True ; do not draw bottom > labels > res at tmYLOn = True ; no bottom tickmarks > else > res at tmYLLabelsOn = False ; do not draw bottom > labels > res at tmYLOn = False ; no bottom tickmarks > end if > > > > > > plot(gg) = gsn_csm_contour_map(wks,pr4({-40:10},{-10:70}),res) ; > create plot > plot2 = gsn_csm_xy(wks,pr2&lon,data,sres) ; create plot > plot3 = gsn_csm_xy(wks,pr5&lon,datac,cres) ; create plot > overlay(plot(gg),plot2) > overlay(plot(gg),plot3) > > delete(pr4) > end do > > ; panel resource list (if necessary) > > panres = True ; mod panel plot > panres at gsnPanelLabelBar = True ; add common colorbar > panres at lbLabelFontHeightF =.012 ; make labels larger > panres at gsnMaximize = True ; Maximize plot in frame. > > gsn_panel(wks,plot(:23),(/6,4/),panres) ; panel 16 models at a time. > gsn_panel(wks,plot(24:),(/6,4/),panres) > ;gsn_panel(wks,plot(32:),(/4,4/),panres) > ;gsn_panel(wks,plot(25:32),(/4,4/),panres) > ;gsn_panel(wks,plot(33:),(/4,2/),panres) > ;gsn_panel(wks,plot(41:),(/4,2/),panres) > ;gsn_panel(wks,plot(::),(/4,2/),panres) > end > > > > Dr. Melissa Lazenby > Lecturer in Climate Change > Department of Geography > Chichester 1 C150 > University of Sussex > > *"Education is the most powerful weapon which you can use to change the > world" Nelson Mandela* > > > _______________________________________________ > 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: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 583899 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image.png Type: image/png Size: 378613 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Outlook-yklt2iha.png Type: image/png Size: 24937 bytes Desc: not available URL: From g.graffino at tim.it Wed Sep 28 13:22:27 2022 From: g.graffino at tim.it (Giorgio Graffino) Date: Wed, 28 Sep 2022 21:22:27 +0200 (CEST) Subject: [ncl-talk] ExcludeOuterBoxes in gsn_create_labelbar Message-ID: <25acc2df.13675.183858ce6d7.Webtop.46@tim.it> Dear NCL Community, I'm trying to set the resource cnLabelBarEndStyle to "ExcludeOuterBoxes" while calling gsn_create_labelbar, to get ride of the labelbar boxes bigger than 1 and smaller than -1 in the attached plot. However, since I'm not drawing a contour plot, the resource doesn't do anything. I'm adapting this example (https://www.ncl.ucar.edu/Applications/Scripts/table_8.ncl). The procedure drawing the labelbar is shown below. How can I solve the issue? I tried to look for a solution in the quick search bar in https://www.ncl.ucar.edu/Support/posting_guidelines.shtml, but it's always giving me the following error "The requested page could not be found." Cheers, Giorgio undef("add_labelbar") procedure add_labelbar(wks,plot,cmap,labels,stride,title,location) local nboxes, vph, vpw, nboxes, lbres, lbid, amres, annoid begin nboxes = dimsizes(labels)+1 colors = span_color_rgba(cmap,nboxes) getvalues plot ; Get plot size for use in "vpHeightF" : vph ; creating labelbar. "vpWidthF" : vpw end getvalues ; ; Set some resources for a vertical or horizontal labelbar on the ; bottom or right axis. ; ; am_para/am_orth ; 0.0/ 0.0 - annotation in dead center of plot ; 0.5/ 0.5 - annotation at bottom right of plot ; 0.5/-0.5 - annotation at top right of plot ; -0.5/-0.5 - annotation at top left of plot ; -0.5/ 0.5 - annotation at bottom left of plot ; ; You will likely need to modify the am_para/am_orth ; values depending on your X and Y axis labels, the size ; of your plot, the number of rows and columns you have, et. ; if(any(location.eq.(/"bot1","bot2"/))) then orient = "horizontal" width = vpw * 0.95 ; slightly shorter than width of plot height = vph * 0.15 am_just = "BottomCenter" am_para = 0.0 ; Centered about X axis title_pos = "Top" if(location.eq."bot1") am_orth = 0.85 ; Move labelbar down else am_orth = 1.04 ; move further down end if else orient = "vertical" width = vpw * 0.15 height = vph * 0.95 ; slightly shorter than height of plot am_just = "TopLeft" am_orth = -0.5 ; Move labelbar up title_pos = "Left" if(location.eq."rgt2") am_para = 0.55 ; Move labelbar right else am_para = 0.78 ; move further right end if end if ; labelbar resources lbres = True lbres at lbAutoManage = False ; Necessary to control sizes lbres at vpWidthF = width lbres at vpHeightF = height lbres at cnLabelBarEndStyle = "ExcludeOuterBoxes" lbres at lbFillColors = colors ; labelbar colors lbres at lbMonoFillPattern = True ; Solid fill pattern lbres at lbLabelFontHeightF = 0.015 ; font height. Default is small lbres at lbLabelAlignment = "InteriorEdges" lbres at lbOrientation = orient lbres at lbTitleString = title lbres at lbPerimOn = False lbres at lbTitlePosition = title_pos lbres at lbLabelStride = stride lbid = gsn_create_labelbar(wks,nboxes,labels,lbres) ; annotation resources amres = True amres at amJust = am_just amres at amOrthogonalPosF = am_orth amres at amParallelPosF = am_para ; attach the labelbar to the plot plot at annoid = gsn_add_annotation(plot,lbid,amres) end -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: HadCM3_plot_maps_cor_10a.png Type: image/png Size: 19971 bytes Desc: not available URL: