<div dir="ltr"><div>I accidentally sent the previous email befor I finished:</div><div><br></div><div>[6]</div><div><div><br></div><div><div> LATS = 30</div><div> LATN = 90</div><div> LONW = 110</div><div> LONE = 150</div><div><br></div><div> sst = <a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml"><b>short2flt</b></a>( f->sst(:,<span style="color:rgb(0,0,255)"><b>{</b></span>LATS:LATN<span style="color:rgb(0,0,255)"><b>}</b></span>,<span style="color:rgb(0,0,255)"><b>{</b></span>LON<span style="color:rgb(0,0,255)"><span style="color:rgb(0,0,0)">W:LONE</span><b>}</b></span>)</div> <b>printVarSummary</b>(sst)</div><div><br></div><div>Look at the coordinate information.</div><div><br></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 20, 2019 at 11:16 AM Dennis Shea <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> <div>I <b>think</b> I understand what you want to do. You use:<br></div><div><br></div><div>[A] This following uses <b>standard subscripting (indexing):</b></div><div><b> <br></b></div><div>print("sst(n,<b>90-30,130</b>)="+sst(n,<b>90-30,130)</b>+" "+lon(130)+"E "+lat(90-30)+"N")<br>print("sstre(n,130,90+30-1)="+sstre(n,130,90+30-1)+" "+lon(130)+"E<br>"+sstre&lat(90+30-1)+"N")</div><br><div><br></div><div>[B] I think you intended to use <b><a href="https://www.ncl.ucar.edu/Document/Language/subscript_coord.shtml" target="_blank">coordinate subscripting</a> </b>which uses the following syntax: <b><span style="color:rgb(0,0,255)">{</span>...<span style="color:rgb(0,0,255)">}</span><br></b></div><div>A 'best practices' programming style is to use variables rather than hard-wiring numbers. Generally, this makes ithe intended use more clear.<br></div><div><br></div><div> LATS = 30</div><div> LATN = 90</div><div> LON = 130</div><div><br></div><div> SST = sst(n,<span style="color:rgb(0,0,255)"><b>{</b></span>LATS:LATN<span style="color:rgb(0,0,255)"><b>}</b></span>,<span style="color:rgb(0,0,255)"><b>{</b></span>LON<span style="color:rgb(0,0,255)"><b>}</b></span>)</div><div> printVarSummary(SST)</div><div><br></div><div>or, say<br></div><div><div> LATS = 30</div><div> LATN = 90</div><div> LONW = 110</div><div> LONE = 150<br></div><div><br></div><div> SST = sst(n,<span style="color:rgb(0,0,255)"><b>{</b></span>LATS:LATN<span style="color:rgb(0,0,255)"><b>}</b></span>,<span style="color:rgb(0,0,255)"><b>{</b></span>LON<span style="color:rgb(0,0,255)"><b>W:LONE}</b></span>)</div><div> printVarSummary(SST)</div></div><div><br></div><div>=================================<br></div><div>[1] Your file variable is:<br><b></b></div><div><b> short </b>sst(time, lat, lon) <br></div><div><br></div><div> The coordinates are:</div><div><br></div><div> Coordinates: <br> time: [66443..80078]<br> <b>lat: [89.5..-89.5] ; <=== North-to-South ordering</b><br> lon: [0.5..359.5]<br></div><div><br></div><div>[2] NCL has the <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml" target="_blank"><b>short2flt </b></a>function that unpacks an maintains meta data. <br></div><div><br></div><div> sst =<b> short2flt</b>( f->sst ) <b>; import and unpack the variable maintaining meta data<br></b></div><div><b> <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/printVarSummary.shtml" target="_blank">printVarSummary</a>(sst)</b></div><div> <a href="https://www.ncl.ucar.edu/Document/Functions/Contributed/printMinMax.shtml" target="_blank"><b>printMinMax</b></a>(sst,0)</div><div><br></div><div>[3] It is not necessary to explicitly read the following coordinate variables from the file. NCL imports the variable as a <b>data structure</b> ['object'] that contains the array values and meta data including coordinate information associated with the variable.</div><div><br></div><div>time = sst<b>&</b>time <br></div><div>lat = sst<b>&</b>lat</div><div>lon = sst<b>&</b>lon</div><div><br></div><div>[4] There are different methods for accessing subsets of a variable: classic indexing and coordinate variable indexing. See above.</div><div><br></div><div>[5] Generally, <b>NCL graphics</b> <b>are aware of coordinate order.</b> Hence, no reordering is necessary. <br></div><div><br></div><div>---</div><div>[6] <br></div><div><br></div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, May 19, 2019 at 9:46 PM Atsuyoshi MANDA <<a href="mailto:am@bio.mie-u.ac.jp" target="_blank">am@bio.mie-u.ac.jp</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">Hi,<br>
<br>
I am trying to reorder the array dimensions in the monthly mean OISST<br>
version 2 dataset, which was downloaded from<br>
<a href="ftp://ftp.cdc.noaa.gov/Datasets/noaa.oisst.v2/sst.mnmean.nc" rel="noreferrer" target="_blank">ftp://ftp.cdc.noaa.gov/Datasets/noaa.oisst.v2/sst.mnmean.nc</a>.<br>
<br>
However, reordering using the named subscripting in my script does not work.<br>
<br>
Please see the attached files:<br>
OIV2LR.sst.1982JUL.png (original data)<br>
OIV2LR.sstre.1982JUL.png (reordered data)<br>
<br>
Any suggestions would be greatly appreciated.<br>
<br>
Here is my script:<br>
;=========================<br>
indir="./"<br>
infle="<a href="http://sst.mnmean.nc" rel="noreferrer" target="_blank">sst.mnmean.nc</a>"<br>
in=indir+"/"+infle<br>
<br>
script_name = get_script_name()<br>
outdir="BIN_"+systemfunc("basename "+script_name+" .ncl")<br>
<br>
dset="OIV2LR"<br>
MM=7<br>
<br>
month_abbr = (/"","JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP", \<br>
"OCT","NOV","DEC"/)<br>
MMM=month_abbr(MM)<br>
<br>
system("mkdir -vp "+outdir)<br>
<br>
<br>
f=addfile(in, "r")<br>
<br>
;printVarSummary(f)<br>
;print(f)<br>
<br>
lon=f->lon<br>
lat=f->lat<br>
sst=f->sst<br>
time=f->time<br>
<br>
utc_date = cd_calendar(time, 0)<br>
<br>
year = tointeger(utc_date(:,0)) ; Convert to integer for<br>
month = tointeger(utc_date(:,1)) ; use sprinti<br>
day = tointeger(utc_date(:,2))<br>
hour = tointeger(utc_date(:,3))<br>
minute = tointeger(utc_date(:,4))<br>
second = utc_date(:,5)<br>
date_str = sprinti("%0.2iZ ", hour) + sprinti("%0.2i ", day) + \<br>
month_abbr(month) + " " + sprinti("%0.4i", year)<br>
<br>
yyyys=1982<br>
yyyye=2017<br>
<br>
sst_scaled=sst*sst@scale_factor + sst@add_offset<br>
copy_VarAtts(sst,sst_scaled)<br>
copy_VarCoords(sst,sst_scaled)<br>
printVarSummary(sst_scaled)<br>
<br>
sstre=sst_scaled(time|:,lon|:,lat|:)<br>
copy_VarAtts(sst_scaled,sst)<br>
copy_VarCoords(sst_scaled,sstre)<br>
printVarSummary(sstre)<br>
<br>
<br>
<br>
dim=dimsizes(year)<br>
nt=dim(0)<br>
<br>
do n=7,7 ;0,nt-1<br>
<br>
if(year(n) .ge. yyyys .and. year(n) .le. yyyye .and. month(n) .eq. MM)then<br>
print(n+" "+date_str(n))<br>
<br>
<br>
figdir="FIG_"+systemfunc("basename "+script_name+" .ncl")+"_"+dset<br>
system("mkdir -vp "+figdir)<br>
type="png"<br>
<br>
<br>
<br>
figfle=dset+"."+"sstre."+year(n)+MMM+""<br>
fig=figdir+"/"+figfle<br>
<br>
print("figfle="+figfle+"."+type)<br>
<br>
wks = gsn_open_wks(type, fig)<br>
<br>
res=True<br>
res@cnFillOn = True ; turn on color fill<br>
res@cnLinesOn = False ; turn off contour lines<br>
plot1=gsn_csm_contour_map(wks,sstre(n,:,:),res)<br>
<br>
<br>
<br>
figfle=dset+"."+"sst."+year(n)+MMM+""<br>
fig=figdir+"/"+figfle<br>
<br>
print("figfle="+figfle+"."+type)<br>
<br>
wks = gsn_open_wks(type, fig)<br>
<br>
res=True<br>
res@cnFillOn = True ; turn on color fill<br>
res@cnLinesOn = False ; turn off contour lines<br>
plot1=gsn_csm_contour_map(wks,sst(n,:,:),res)<br>
<br>
<br>
print("sst(n,90-30,130)="+sst(n,90-30,130)+" "+lon(130)+"E "+lat(90-30)+"N")<br>
print("sstre(n,130,90+30-1)="+sstre(n,130,90+30-1)+" "+lon(130)+"E<br>
"+sstre&lat(90+30-1)+"N")<br>
<br>
end if<br>
<br>
end do<br>
;=========================<br>
<br>
Thank you,<br>
Atsuyoshi<br>
<br>
-<br>
Atsuyoshi Manda, Ph.D<br>
Associate Professor,<br>
Mie University<br>
1577 Kurimamachiya-cho Tsu city, Mie 514-8507 JAPAN<br>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div></div>
</blockquote></div>