[ncl-talk] Fwd: Re: Errors while trying to plot IAGOS data. Only the contour map plot, but the data is missing.

najib.yusuf at carnasrda.com najib.yusuf at carnasrda.com
Sun Oct 15 04:28:22 MDT 2017



  Hi Adam,
  Thank you for making out time to point out these. I understand what 
each of the newer codes lines are doing but my
  files are not of same length. Is multidimensional array possible with 
different file sizes?

   Thank you

   Najib




On 2017-10-15 00:02, Adam Phillips wrote:
> Hi Najib,
> The errors you are receiving are telling you what is wrong and at what
> line. You have four syntax errors, the first three being caused as you
> are using a comma (,) instead of a semi-colon (;) for comments. (Thus,
> replace each of the three , with a ;.) The fourth syntax error is
> because you have this at line 120:
> res at tmXBLabelFontHeightF =
> You need to specify a value to the right of the equal sign, say,
> 0.020.
> 
> Another error message is due to this line:
> ncl 107> res at xyLineColors = (/"black",\"red", "green",\"blue",\
> "orange","yellow",\"gray",\"purple","majenta",\"orchid1","plum1",\"magenta4""pink1",\"maroon","lightpink4"/)
> fatal:syntax error: line 107 before or near =
> res at xyLineColors =
> -----------------^
> You have a number of unnecessary \ symbols. Remove all of them. Also,
> change majenta to magenta.
> 
> Your final error message tells you explicitly what is wrong:
> fatal:Dimension size mismatch on subscript #1, left-hand and
> right-hand side dimensions do not match
> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 88
> 
> Looking at lines 87-88:
> ncl 87>  data = new((/15,500/),double)
> ncl 88>   data(0,:) = ozone1
> 
> Thus, NCL is telling you that ozone1 is not of size 500. Assuming each
> of your ozone files are exactly the same length, replace this:
> data = new((/15,500/),double)
> 
> with this:
> data = new((/15,dimsizes(ozone1)/),typeof(ozone1))
> 
> Finally, it was pointed out to me by a colleague that you could, if
> all your ozone files are the same length, use addfiles to read all of
> the files in at once and join them using code like this:
> 
> diri = "/home/model-user/2000/"
>   diri = "./"
>   fili = systemfunc("cd "+diri+"; ls *timeseries*nc")
>   sqsort(fili)                  ; make sure these are in ascending
> order
>   print(fili)
>   print("----")
>   nfili= dimsizes(fili)
>   print("nfili="+nfili)
>   print("----")
> 
> ;---Open all files
>   pthi = diri+fili
>   ListSetType (f, "join")
>   f    = addfiles(pthi, "r")
> 
> ;---ozone over all time steps
>   ozone= f[:]->O3_PM
>   ozone at long_name = "O3 volume mixing ratio"    ;
> mole_fraction_of_ozone_in_air
>   printVarSummary(ozone)                        ; ozone(UTC_time)
>   printMinMax(ozone,0)
>   print("----")
> 
> I would recommend only switching to this newer code if your ozone
> arrays are the same length, and if you fully understand what each of
> the above lines is doing.
> 
> If you have any further questions please respond to the ncl-talk email
> list.
> Adam
> 
> On Sat, Oct 14, 2017 at 8:28 AM, <najib.yusuf at carnasrda.com> wrote:
> 
>> Thank you Adam for your help and time.
>> I did as you said but I received subscripting  error as the ozone
>> variable in all the files is 1 dimensional (UTC_time), I attached
>> one of the file output for data sample. Please see the output below;
>> 
>> [model-user at model-vm ~]$ ncl -Q
>> ncl 0> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>> =
>> ncl 1> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>> a
>> ncl 2>
>> ncl 3> begin
>> ncl 4> ;-- read the data and define
>> 2
>> ncl 5>
>> ncl 6> diri = "/home/model-user/2000/"
>> ncl 7> fil1 = "IAGOS_timeseries_2000040222361353.nc [1]"
>> ncl 8> fil2 = "IAGOS_timeseries_2000040922544753.nc [2]"
>> ncl 9> fil3 = "IAGOS_timeseries_2000041122453853.nc [3]"
>> ncl 10> fil4 = "IAGOS_timeseries_2000041217193053.nc [4]"
>> ncl 11> fil5 = "IAGOS_timeseries_2000041220041453.nc [5]"
>> ncl 12> fil6 = "IAGOS_timeseries_2000041222213953.nc [6]"
>> ncl 13> fil7 = "IAGOS_timeseries_2000050222480853.nc [7]"
>> 
>> ncl 14> fil8 = "IAGOS_timeseries_2000050723210353.nc [8]"
>> ncl 15> fil9 = "IAGOS_timeseries_2000051317072253.nc [9]"
>> ncl 16> fil10 = "IAGOS_timeseries_2000051320135353.nc [10]"
>> ncl 17> fil11 = "IAGOS_timeseries_2000051322273853.nc [11]"
>> ncl 18> fil12 = "IAGOS_timeseries_2000053009261035.nc [12]"
>> ncl 19> fil13 = "IAGOS_timeseries_2000060622395953.nc [13]"
>> ncl 20> fil14 = "IAGOS_timeseries_2000071122541553.nc [14]"
>> ncl 21> fil15 = "IAGOS_timeseries_2000071622553453.nc [15]"
>> ncl 22>
>> ncl 23> f1 = addfile(diri+fil1, "r")
>> ncl 24> f2 = addfile(diri+fil2, "r")
>> ncl 25> f3 = addfile(diri+fil3, "r")
>> ncl 26> f4 = addfile(diri+fil4, "r")
>> ncl 27> f5 = addfile(diri+fil5, "r")
>> ncl 28> f6 = addfile(diri+fil6, "r")
>> ncl 29> f7 = addfile(diri+fil7, "r")
>> ncl 30> f8 = addfile(diri+fil8, "r")
>> ncl 31> f9 = addfile(diri+fil9, "r")
>> ncl 32> f10 = addfile(diri+fil10, "r")
>> ncl 33> f11 = addfile(diri+fil11, "r")
>> ncl 34> f12 = addfile(diri+fil12, "r")
>> ncl 35> f13 = addfile(diri+fil13, "r")
>> ncl 36> f14 = addfile(diri+fil14, "r")
>> ncl 37> f15 = addfile(diri+fil15, "r")
>> ncl 38>
>> ncl 39>
>> ncl 40>
>> ncl 41>   ozone1 = f1->O3_PM
>> ncl 42>   ozone1 at long_name = "O3 volume mixing ratio"
>> ncl 43>   ozone2 = f2->O3_PM
>> ncl 44>   ozone2 at long_name = "O3 volume mixing ratio"
>> ncl 45>   ozone3 = f3->O3_PM
>> ncl 46>   ozone3 at long_name = "O3 volume mixing ratio"
>> ncl 47>
>> ncl 48>   ozone4 = f4->O3_PM
>> ncl 49>   ozone4 at long_name = "O3 volume mixing ratio"
>> ncl 50>   ozone5 = f5->O3_PM
>> ncl 51>   ozone5 at long_name = "O3 volume mixing ratio"
>> ncl 52>   ozone6 = f6->O3_PM
>> ncl 53>   ozone6 at long_name = "O3 volume mixing ratio"
>> ncl 54>
>> ncl 55>   ozone7 = f7->O3_PM
>> ncl 56>   ozone7 at long_name = "O3 volume mixing ratio"
>> ncl 57>   ozone8 = f8->O3_PM
>> ncl 58>   ozone8 at long_name = "O3 volume mixing ratio"
>> ncl 59>   ozone9 = f9->O3_PM
>> ncl 60>   ozone9 at long_name = "O3 volume mixing ratio"
>> ncl 61>
>> ncl 62>   ozone10 = f10->O3_PM
>> ncl 63>   ozone10 at long_name = "O3 volume mixing ratio"
>> ncl 64>   ozone11 = f11->O3_PM
>> ncl 65>   ozone11 at long_name = "O3 volume mixing ratio"
>> ncl 66>   ozone12 = f12->O3_PM
>> ncl 67>   ozone12 at long_name = "O3 volume mixing ratio"
>> ncl 68>
>> ncl 69>   ozone13 = f13->O3_PM
>> ncl 70>   ozone13 at long_name = "O3 volume mixing ratio"
>> ncl 71>   ozone14 = f14->O3_PM
>> ncl 72>   ozone14 at long_name = "O3 volume mixing ratio"
>> ncl 73>   ozone15 = f15->O3_PM
>> ncl 74>   ozone15 at long_name = "O3 volume mixing ratio"
>> ncl 75> ;---------------------------------------------------
>> ncl 76>   printVarSummary(ozone15)    , just to see summary of one
>> of the variables
>> fatal:syntax error: line 76 before or near ,
>> printVarSummary(ozone15)    ,
>> ------------------------------^
>> 
>> fatal:error in statement
>> ncl 77>
>> ncl 78>   print ("min/max ozone15 = " + min(ozone15) + "/" +
>> max(ozone15))
>> ncl 79> ;---------------------------------------------------
>> ncl 80>   time = ispan (3600,103598,5) , data time in seconds
>> fatal:syntax error: line 80 before or near ,
>> time = ispan (3600,103598,5) ,
>> -------------------------------^
>> 
>> ncl 81>   long_name = "UTC time"
>> ncl 82> ;----------------------------------------------------
>> ncl 83> ; to plot multiple lines, you must put them into a
>> ncl 84> ; mulidimensional array
>> ncl 85> ;----------------------------------------------------
>> ncl 86>
>> ncl 87>  data = new((/15,500/),double)
>> ncl 88>   data(0,:) = ozone1
>> ncl 89>   data(1,:) = ozone2
>> ncl 90>   data(2,:) = ozone3
>> ncl 91>   data(3,:) = ozone4
>> ncl 92>   data(4,:) = ozone5
>> ncl 93>   data(5,:) = ozone6
>> ncl 94>   data(6,:) = ozone7
>> ncl 95>   data(7,:) = ozone8
>> ncl 96>   data(8,:) = ozone9
>> ncl 97>   data(9,:) = ozone10
>> ncl 98>   data(10,:) = ozone11
>> ncl 99>   data(11,:) = ozone12
>> ncl 100>   data(12,:) = ozone13
>> ncl 101>   data(13,:) = ozone14
>> ncl 102>   data(14,:) = ozone15
>> ncl 103>
>> ncl 104>   wks = gsn_open_wks("png", "O3_PM_ 2000_to & fro
>> lagos_Flights")
>> ncl 105>
>> ncl 106>  res = True
>> ncl 107>  res at xyExplicitLegendLabels =
>> (/"data1",\"data2","data3",\"data4"\,"data5",
>> ncl 107>
>> 
> "data6",\"data7\","data8","data9"\,"data10","data11"\,"data12","data13",\"data14"/)
>> ncl 107> res at xyLineColors = (/"black",\"red", "green",\"blue",\
>> 
> "orange","yellow",\"gray",\"purple","majenta",\"orchid1","plum1",\"magenta4""pink1",\"maroon","lightpink4"/)
>> fatal:syntax error: line 107 before or near =
>> res at xyLineColors =
>> -----------------^
>> 
>> ncl 107> res at xyDashPatterns = (/0, 5, 2, 1, 3, 2, 1, 5, 2, 0, 5, 2,
>> 4, 2, 3\)
>> ncl 107> res at xyLineThicknessF = 3
>> ncl 108> res at tiYAxisString = "O3_PM ppb"
>> ncl 109> res at tiYAxisFont = 21
>> ncl 110> res at tiYAxisFontAspectF = 1.3
>> ncl 111> res at tiYAxisFontHeightF = 0.012
>> ncl 112> res at tiXAxisString = "Time"
>> ncl 113> res at tiXAxisFont = 21
>> ncl 114> res at tiXAxisFontAspectF = 1.3
>> ncl 115> res at tiXAxisFontHeightF = 0.012
>> ncl 116> res at tiXAxisOffsetYF = 0.0
>> ncl 117> res at tiMainOffsetYF = 0.11
>> ncl 118> res at tiMainString = "Ozone to and fro Lagos Flights 2000"
>> ncl 119> res at tmXBLabelFontAspectF = 1.3
>> ncl 120> res at tmXBLabelFontHeightF =
>> fatal:syntax error: line 120 before or near \n
>> res at tmXBLabelFontHeightF =
>> --------------------------^
>> 
>> ncl 121> res at trYMinF = 10.0
>> ncl 122> res at trYMaxF = 200.0
>> ncl 123> res at gsnDraw = Fa
>> ncl 124> res at gsnFrame = False
>> ncl 125> res at vpXF = 0.2
>> ncl 126> ;-- set viewport resources
>> ncl 127> res at vpYF = 0.6
>> ncl 128> res at vpWidthF = 0.7
>> ncl 129> res at pmLegendDisplayMode = "Always"
>> ncl 130> res at pmLegendWidthF = 0.12 ;-- set legend width
>> ncl 131> res at pmLegendHeightF = 0.19 ;-- set legend height
>> ncl 132> res at pmLegendParallelPosF = 0.18 ;-- move legend right
>> ncl 133> ;-- create plot
>> ncl 134> plot = gsn_csm_xy(wks,time,data,res)
>> ncl 135>
>> ncl 136> ;-- draw the plot
>> ncl 137> draw(plot)
>> ncl 138> frame(wks)
>> ncl 139> end
>> (0)     min/max ozone15 = 2/479
>> fatal:Dimension size mismatch on subscript #1, left-hand and
>> right-hand side dimensions do not match
>> fatal:["Execute.c":8573]:Execute: Error occurred at or near line 88
>> 
>> On 2017-10-13 14:24, Adam Phillips wrote:
>> Hi Najib,
>> As a reminder, always include any error messages that you getting as
>> that would assist the ncl-talk community with diagnosing the
>> problem.
>> 
>> You have the following coding:
>> 
>> data = new((/15,500/),double)
>> data0 = ozone1
>> data1 = ozone2
>> <snip>
>> data14 = ozone15
>> 
>> You are copying the ozone1 array to a new array named data0, the
>> ozone2 array to data1, and so on. You are not infilling your data
>> array.
>> 
>> Then, you are calling the plotting function like this:
>> plot = gsn_csm_xy(wks,time,data,res)
>> 
>> Thus, I am guessing that nothing is being plotted as data is empty.
>> 
>> Swap this:
>> 
>> data = new((/15,500/),double)
>> data0 = ozone1
>> data1 = ozone2
>> <snip>
>> data14 = ozone15
>> 
>> with this:
>> 
>> data = new((/15,500/),double)
>> data(0,:) = ozone1
>> data(1,:) = ozone2
>> <snip>
>> data(14,:) = ozone15
>> 
>> If you have any further questions please respond to the ncl-talk
>> email
>> list.
>> Adam
>> 
>> On Fri, Oct 13, 2017 at 4:25 AM, <najib.yusuf at carnasrda.com> wrote:
>> 
>> Dear ncl talk,
>> 
>> Thank you for your guidance all the time. I am able to plot using
>> time series. However, I proceeded to modify the script to plot
>> multiple time series  (15 files) by following the example in
>> NCL_User_Guide " This example is saved in NUG_multi_timeseries.ncl."
>> But i am having a problem with multidimensional array because my
>> files have different sizes. Kindly direct me.
>> 
>> Attached are the two files.
>> 
>> Thank you
>> 
>> Najib
>> 
>> On 2017-09-27 13:41, Dennis Shea wrote:
>> You stated:  "I tried solving but couldn't get it"
>> 
>> Please look at the output from your commands.
>> 
>> The  output is  for *you* to look at.
>> 
>> ----
>> 
>> More on David's comment ...
>> 
>> re: GOLDEN RULE OF DATA PROCESSING... LOOK AT YOUR DATA
>> 
>> You used:
>> 
>> var = f->O3_PM(0)   <==== the reads only the 1st value [index (0)
>> ]
>> 
>> Variable: var
>> Type: double
>> Total Size: 8 bytes
>> 1 values           <=== ONE VALUE ... how do you contour
>> one value?
>> 
>> ---
>> 
>> The min & max are _FillValue. Look at the output from your script.
>> 
>> (0)    min/max var = -9999/-9999
>> ---
>> 
>> Even if you read  the entire *time  series* ... all values are
>> _FillValue
>> 
>> var = f->O3_PM    ;   entire series
>> 
>> printVarSummary(var)
>> 
>> Variable: var
>> Type: double
>> Total Size: 63024 bytes
>> 7878 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [UTC_time | 7878]    <=========
>> Coordinates:
>> UTC_time: [70841..106359]
>> Number Of Attributes: 8
>> standard_name :       mole_fraction_of_ozone_in_air
>> long_name :   Ozone mixing ratio
>> comment :     Measured by MOZAIC package
>> units :       0.000000001
>> missing_value :       -9999
>> _FillValue :  -9999
>> scale_factor :         1
>> availability :         0
>> 
>> print ("min/max var = " + min(var) + "/" + max(var))
>> (0)     MIN/MAX VAR = -9999/-9999
>> 
>> ---
>> 
>> It should be plotted as a time series not as a contour plot.
>> 
>> On Wed, Sep 27, 2017 at 10:34 AM, David Brown <dbrown at ucar.edu>
>> wrote:
>> 
>> You will never be able to contour the O3_PM variable from this file
>> because it contains only fill values:
>> 
>> ncl 0> f = addfile("IAGOS_timeseries_2013101819404151.nc [16] [1]
>> [1]","r")
>> ncl 1> printMinMax(f->O3_PM,0)
>> (0) Ozone mixing ratio (0.000000001) : min=-9999   max=-9999
>> 
>> Presumably this is what the attribute "availability" means: no valid
>> values for this variable.
>> 
>> Also for some reason your variable "var" contains only a single
>> value.
>> There is no way to make a contour plot with only one point even if
>> it
>> were a valid value. Since the only dimension in the file is a time
>> dimension, maybe this data set would be better displayed as a time
>> series x-y plot.
>> -dave
>> 
>> On Wed, Sep 27, 2017 at 8:16 AM,  <najib.yusuf at carnasrda.com> wrote:
>> 
>> Dear Sirs,
>> 
>> I try to plot contour map of O3_PM variable from .nc IAGOS file
>> but I am
>> getting strange errors, I tried solving but couldn't get it.
>> Kindly assist
>> to guide. Attached is the file and the IAGOS.ncl as script.Thank
>> you.
>> 
>> The summary of the print var is;
>> 
>> Variable: var
>> Type: double
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [UTC_time | 1]
>> Coordinates:
>> Number Of Attributes: 9
>> UTC_time :    70841
>> standard_name :       mole_fraction_of_ozone_in_air
>> long_name :   Ozone mixing ratio
>> comment :     Measured by MOZAIC package
>> units :       0.000000001
>> missing_value :       -9999
>> _FillValue :  -9999
>> scale_factor :         1
>> availability :         0
>> 
>> Variable: var
>> Type: double
>> Total Size: 8 bytes
>> 1 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [UTC_time | 1]
>> Coordinates:
>> Number Of Attributes: 9
>> UTC_time :    70841
>> standard_name :       mole_fraction_of_ozone_in_air
>> long_name :   Ozone mixing ratio
>> comment :     Measured by MOZAIC package
>> units :       0.000000001
>> missing_value :       -9999
>> _FillValue :  -9999
>> scale_factor :         1
>> availability :         0
>> (0)     -9999
>> (0)     min/max var = -9999/-9999
>> fatal:MeshScalarFieldInitialize: Insufficient number of elements
>> in
>> sfDataArray
>> fatal:Unable to initialize layer-Can't Create
>> fatal:Unable to access object with id:-4
>> fatal:Unable to access object with id:-4
>> warning:Unable to add DataItem "(null)" to DataList
>> "cnScalarFieldData"
>> fatal:CompileDataList:DataList has no valid members
>> warning:ContourPlotSetValues: cnLevelSpacingF value causes level
>> count to
>> exceed maximum: using AUTOMATICLEVELS mode
>> ncl 48>
>> 
>> Thank you
>> 
>> Najib
>> 
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk [17] [2] [2]
>> 
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk [17] [2] [2]
>> 
>> Links:
>> ------
>> [1] http://2013101819404151.nc
>> [2] http://mailman.ucar.edu/mailman/listinfo/ncl-talk [17] [2]
>> 
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk [17] [2]
>> 
>> --
>> 
>> Adam Phillips
>> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
>> 
>> www.cgd.ucar.edu/staff/asphilli/ [18] [3]   303-497-1726 [19] [4]
>> 
>> [5]
>> 
>> Links:
>> ------
>> [1] http://2013101819404151.nc
>> [2] http://mailman.ucar.edu/mailman/listinfo/ncl-talk [17]
>> [3] http://www.cgd.ucar.edu/staff/asphilli/ [18]
>> [4] tel:(303)%20497-1726
>> [5] http://www.cgd.ucar.edu/staff/asphilli [20]
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk [17]
> 
> --
> 
> Adam Phillips
> Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
> 
> www.cgd.ucar.edu/staff/asphilli/ [18]   303-497-1726
> 
>  [20]
> 
> Links:
> ------
> [1] http://2000040222361353.nc
> [2] http://2000040922544753.nc
> [3] http://2000041122453853.nc
> [4] http://2000041217193053.nc
> [5] http://2000041220041453.nc
> [6] http://2000041222213953.nc
> [7] http://2000050222480853.nc
> [8] http://2000050723210353.nc
> [9] http://2000051317072253.nc
> [10] http://2000051320135353.nc
> [11] http://2000051322273853.nc
> [12] http://2000053009261035.nc
> [13] http://2000060622395953.nc
> [14] http://2000071122541553.nc
> [15] http://2000071622553453.nc
> [16] http://2013101819404151.nc
> [17] http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> [18] http://www.cgd.ucar.edu/staff/asphilli/
> [19] tel:303-497-1726
> [20] http://www.cgd.ucar.edu/staff/asphilli


More information about the ncl-talk mailing list