[ncl-talk] NCL Creating Time Series Plots
Smith, Stuart
smit1770 at purdue.edu
Fri Jan 19 15:27:09 MST 2018
Good afternoon Adam,
Thank you for the input. I’ve learned a lot. In the example you provided, “data” was assumed to have the variable time with the depth of water. In my .nc files depth of water and time are not named in the same dimension.
As a result I get the following message, “fatal:(time) is not a named dimension in variable (data). “ I tried to adjust the script by assigning a time variable to the defined data variable as shown below. However, this was unsuccessful. Any advice? Thank you for your time.
begin
diri = "/scratch/conte/s/smit1770/RRB_Test_Simulation/RedRiver/OUTPUT_8x6.1hr_2018/SURFACEMODEL/200903/"
;fils = systemfunc("ls *.d01.nc")
fils = systemfunc("ls "+diri+"*.d01.nc")
;print(fils) ; make sure the desired files are listed in the correct order
a = addfiles(fils,"r")
data = a[:]->vic_lake_depth_inst
data at time=a[:]->time
;time = a[:]->time ; assuming variable name is Depth_of_water
;print(time)
;print(data)
print(data&time) ; check that the times read in are correct
;printVarSummary(data) ; examine data array
data_aa = wgt_areaave(data,1.,1.,0) ; Not applying any area-weight to the data
wks = gsn_open_wks("png","timeseries")
res = True
res at tmXBMode = "Explicit" ; explicit labels
res at tmXBValues = time ; location of labels
res at tmXBLabels = "Test" ; labels themselves
res at tmLabelAutoStride = True ; nice stride on labels
res at tiMainString = "Explicit axis labeling"; title
;plot = gsn_csm_xy(wks,ispan(0,dimsizes(data&time)-1,1,data_aa,res)
plot = gsn_csm_xy(wks,ispan(0,dimsizes(data&time)-1,1),data_aa,res)
end
Regards,
-Stuart
From: Adam Phillips [mailto:asphilli at ucar.edu]
Sent: Thursday, January 18, 2018 12:32 PM
To: Smith, Stuart <smit1770 at purdue.edu>
Cc: Ncl-talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] NCL Creating Time Series Plots
Hi Stuart,
If the files are sequentially named, you can use addfiles to read all the files at once:
begin
fils = systemfunc("ls *.d01.nc <http://d01.nc> ")
print(fils) ; make sure the desired files are listed in the correct order
a = addfiles(fils,"r")
data = a[:]->Depth_of_water ; assuming variable name is Depth_of_water
print(data&time) ; check that the times read in are correct
printVarSummary(data) ; examine data array
data_aa = wgt_areaave(data,1.,1.,0) ; Not applying any area-weight to the data
wks = gsn_open_wks("png","timeseries")
res = True
... ; set desired resources here
plot = gsn_csm_xy(wks,ispan(0,dimsizes(data&time)-1,1,data_aa,res)
end
Note:
1 - Make sure that the results from systemfunc list the files that you want to read in in the correct order.
2 - You may very well want to area weight the data, and this may have to be done by hand as I do not believe a function exists that can do that on an array with 2-dimensional latitudes/longitudes.
3 - There are lots of different resources that can be set for timeseries, specifically for the tickmarks. Review the examples here:
http://www.ncl.ucar.edu/Applications/xy.shtml
http://www.ncl.ucar.edu/Applications/time_labels.shtml
http://www.ncl.ucar.edu/Applications/tickmarks.shtml
Hope that helps. If you have any further questions please respond to the ncl-talk email list.
Adam
On Wed, Jan 17, 2018 at 2:24 PM, Smith, Stuart via ncl-talk <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu> > wrote:
Good afternoon,
My name is Stuart, and I am research assistant at Purdue University.. I tried using the serach ncl-talk archives, but received a “URL Not Found” message.
I am wanting to learn about generating time series plots with .nc files. The .nc files I have are daily timesteps (200903250000.d01.nc <http://200903250000.d01.nc> , 200903260000.d01.nc <http://200903260000.d01.nc> ). I would like to plot the .nc files as a spatially averaged(ex. Depth of water) time series plot for an entire month.
The dimension of time is 1, as to be expected. The dimension of the variable of interest is 2 [north_south|32] x [east_west |45]. My goal would be to calculate the average value over this area, and plot it with the appropriate day to create the time series.
Could you please provide some examples of how this problem has been solved in the past? Thank you for your time.
Regards,
-Stuart
_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ <http://www.cgd.ucar.edu/staff/asphilli/> 303-497-1726
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180119/7fcaa6b2/attachment-0001.html>
More information about the ncl-talk
mailing list