[ncl-talk] Regarding Problem in Correlation Plot in NCL

Dennis Shea shea at ucar.edu
Wed Mar 27 11:42:01 MDT 2019


ALWAYS include a printVarSummary for variables in question. How is ncl-talk
to know this information?

WHY are you explicitly converting short-to-float and explicitly naming
dimensions?

Please use: *short2flt*
<https://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml>

This will clean up most of your code. The following has 'lots' or print*
lines.
The 'golden rule' in data processing and programming is: Know Your Data!
--
lat0=0
lat1=40
lon0=20
lon1=150
f1=addfile("daily_1.nc
<https://urldefense.proofpoint.com/v2/url?u=http-3A__daily-5F1.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=Oy4Q6oTBGw-AUYsg0wqI2QibatzuHVHBoD2bUwu3E9w&e=>
","r")
f2=addfile("daily_2.nc
<https://urldefense.proofpoint.com/v2/url?u=http-3A__daily-5F2.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=f7vZDcv0bvgoO0xxKTh4DalxHLSK1FXgeeOUmANKmNA&e=>
","r")

sst = *short2flt*( f1->sst(:,{lat0:lat1},{lon0:lon1}) )
printVarSummary(sst)
printMinMax(sst.0)
print("---")

sst = sst-273.15
sst at units = "degC"
printVarSummary(sst)
printMinMax(sst,0)
print("---")

vo = short2flt(f2->vo(:,{lat0:lat1},{lon0:lon1}))
printVarSummary(vo)
printMinMax(vo,0)
print("---")

vo=vo*(10^5)   ; scale
vo at units = "degC"
vo at info   = "Source vo values were scaled by 10^5"
printVarSummary(vo)
printMinMax(vo,0)
print("---")

ts1 = sst(lat|:,lon|:,time|:)
ts2 = vo(lat|:,lon|:,time|:)
maxlag = 2
lag = 0
ccr = esccr(ts1,ts2,maxlag)

printVarSummary(ccr)
printMinMax(ccr,0)
print("---")



On Wed, Mar 27, 2019 at 7:18 AM Toni Klemm <toni-klemm at tamu.edu> wrote:

> Sir,
>
> Please always reply to ncl-talk at ucar.edu, not just to the person who
> emailed you. That way others can chime in, too, and your question is
> archived.
>
> Are you sure this all of your code? The error message says the error is in
> line 421, but you only included 75 lines of code. Also, I don’t see any
> loops or “begin” and “end” at the front and back end of your code. Could
> you include all your code, from “begin” to “end”?
>
> Thanks,
> Toni
>
>
> *Toni Klemm**, Ph.D.*
> Postdoctoral Research Associate
> Department of Ecosystem Science and Management
> College of Agriculture and Life Sciences
> Texas A&M University, College Station, TX
> Contributor to the Early Career Climate Forum <https://www.eccforum.org/>
> www.toni-klemm.de | @toniklemm <https://twitter.com/ToniKlemm>
>
>
>
>
>
>
> On Mar 27, 2019, at 5:59 AM, Ashutosh K Sinha <ashutoshsinha at cusb.ac.in>
> wrote:
>
> lat0=0
> lat1=40
> lon0=20
> lon1=150
> f1=addfile("daily_1.nc
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__daily-5F1.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=Oy4Q6oTBGw-AUYsg0wqI2QibatzuHVHBoD2bUwu3E9w&e=>
> ","r")
> f2=addfile("daily_2.nc
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__daily-5F2.nc&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=f7vZDcv0bvgoO0xxKTh4DalxHLSK1FXgeeOUmANKmNA&e=>
> ","r")
> sst=f1->sst(:,{lat0:lat1},{lon0:lon1})
> latsfc=f1->latitude({lat0:lat1})
> lonsfc=f1->longitude({lon0:lon1})
> timesfc=f1->time
> sstcT=(sst*sst at scale_factor)+sst at add_offset
> sstc=sstcT-273.15
> sstc!0="time"
> sstc!1="lat"
> sstc!2="lon"
> sstc&time=timesfc
> sstc&lat=latsfc
> sstc&lon=lonsfc
> sstc at units=sst at units
> vo=f2->vo(:,{lat0:lat1},{lon0:lon1})
> lathpa=f2->latitude({lat0:lat1})
> lonhpa=f2->longitude({lon0:lon1})
> timehpa=f2->time
> vocT=(vo*vo at scale_factor)+vo at add_offset
> voc=vocT*(10^5)
> voc!0="time"
> voc!1="lat"
> voc!2="lon"
> voc&lat=lathpa
> voc&lon=lonhpa
> voc&time=timehpa
> voc at units=vo at units
> ts1 = sstc(lat|:,lon|:,time|:)
> ts2 = voc(lat|:,lon|:,time|:)
> maxlag = 2
> lag = 0
> ccr = esccr(ts1,ts2,maxlag)
> copy_VarAtts(ts1,ccr)
> copy_VarCoords_1(ts2,ccr)
> wks = gsn_open_wks("png","correlation1")
> res=True
> res at gsnDraw=False
> res at gsnFrame=False
> res at gsnAddCyclic = False
> res at gsnMaximize    = False
> res at tiMainString = "Correlation_Surface-850"
> res at tiMainStringOrthogonalPosF=0.5
> res at gsnLeftString = ""
> res at gsnRightString = ""
> res at tmXTOn         = False
> res at tmYROn         = False
> res at lbLabelBarOn =""
> res at mpMinLatF = lat0
> res at mpMaxLatF = lat1
> res at mpMinLonF = lon0
> res at mpMaxLonF = lon1
> res at mpOutlineOn = True
> res at mpGeophysicalLineThicknessF = 4
> res at mpNationalLineThicknessF = 4
> res at mpFillDrawOrder = "PostDraw"
> res at mpFillOn = False
> res at cnLevelSelectionMode = "ManualLevels"
> res at cnMinLevelValF = -1.
> res at cnMaxLevelValF =  1.
> res at cnLevelSpacingF = 0.1
> res at cnLabelBarEndStyle = "ExcludeOuterBoxes"
> res at pmLabelBarWidthF     = 0.8
> res at cnFillDrawOrder = "PreDraw"
> res at cnFillOn = True
> res at cnLinesOn = True
> res at cnLineLabelsOn = True
> map = gsn_csm_contour_map(wks,ccr(:,:,lag),res)
> draw(map)
> frame(wks)
>
> **** sst is for Sea Surface Temperature and vo for Vorticity
>
> Ashutosh K Sinha
> PhD Student - Environmental Sciences
> *(**Central University of South Bihar, Gaya, India)*
>
> *Never Give Up*
>
>
> Central University Of South BiharPlease enter your username and password
> to continue.
> Username:
> Password:
>
> On Wed, Mar 27, 2019 at 3:57 PM Toni Klemm <toni-klemm at tamu.edu> wrote:
>
>> Sir,
>>
>> Could you include your code? It looks like something is wrong with an if
>> condition or a do loop, but it‘s hard to pinpoint without seeing your code.
>>
>> Toni
>>
>>
>> *Toni Klemm**, Ph.D.*
>> Postdoctoral Research Associate
>> Department of Ecosystem Science and Management
>> College of Agriculture and Life Sciences
>> Texas A&M University, College Station, TX
>> Contributor to the Early Career Climate Forum
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__www.eccforum.org_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=DdmI6LDEkRhKEwr39FKOFsqPcgaS2kP9iAIx_rvsbWc&e=>
>> www.toni-klemm.de
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.toni-2Dklemm.de_&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=E33q5sdAzGskdONfaPG5_nqvLX2H_sdH-V677rrSJKk&e=>
>>  | @toniklemm
>> <https://urldefense.proofpoint.com/v2/url?u=https-3A__twitter.com_ToniKlemm&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=s3h4u2mZUQl9pt-bIidT0hSPWKW4OqlBkv5azinatV8&e=>
>>
>>
>> On Mar 27, 2019, at 4:43 AM, Ashutosh K Sinha <ashutoshsinha at cusb.ac.in>
>> wrote:
>>
>> Greetings!!
>>
>> I am trying to plot correlation using esccr or escor however I have been
>> getting errors as
>> map = gsn_csm_contour_map(wks,ccr(:,:,lag),res)
>> fatal:Conditional statements (if and do while) require SCALAR logical
>> values, see all and any functions
>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 7796 in
>> file /home/NCL-6.4.0/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>
>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 11285 in
>> file /home/NCL-6.4.0/lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>
>> fatal:["Execute.c":8638]:Execute: Error occurred at or near line 421
>>
>> What should I do?
>>
>> Ashutosh K Sinha
>> PhD Student - Environmental Sciences
>> *(**Central University of South Bihar, Gaya, India)*
>>
>>
>> *Never Give Up*
>>
>> Central University Of South BiharPlease enter your username and password
>> to continue.
>> Username:
>> Password:
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.ucar.edu_mailman_listinfo_ncl-2Dtalk&d=DwMFaQ&c=ODFT-G5SujMiGrKuoJJjVg&r=WsLJ5ywbW3XnTzqo_ETV62H6s1a5bcGgnrpl7xPRfic&m=hhdYutZEmgES2blVqSqB_MtEv5ixmzewdClL37_xzI0&s=Mbzq7AkG0gKTtIU8r-BIukGUDNX37orir9Ru3SbQjRg&e=>
>>
>>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190327/e462395a/attachment.html>


More information about the ncl-talk mailing list