;---Read the file names ;---https://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml diri = "/home/model-user/2000/" fili = systemfunc("cd "+diri+"; ls *timeseries*nc") sqsort(fili) ; make sure these are in ascending order print(fili) print("----") nfili= dimsizes(fili) ; number of files print("nfili="+nfili) print("----") ;---Open all files: (a) f[:] means 'all' files; [b] f[nf] for individual fiules ;---https://www.ncl.ucar.edu/Document/Functions/Built-in/addfiles.shtml pthi = diri+fili f = addfiles(pthi, "r") ;---Every file has a *different* number of time steps ;---Find max number of time steps NTIM = 0 do nf=0,nfili-1 NTIM = max( (/NTIM, dimsizes(f[nf]->UTC_time) /) ) end do print("NTIM="+NTIM) print("----") ;---Create 'super' array; fill with values data = new((/nfili,NTIM/),double, -999d) ; all fields are type double do nf=0,nfili-1 ntim = dimsizes(f[nf]->UTC_time) data(nf,0:ntim-1) = f[nf]->O3_PM ; fill only the appropriate number of values end do printVarSummary(data) printMinMax(data,0) print("----") ;---Extract assorted information; assume all the same departure/arrival airports ;---https://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml depAir = str_get_field(f[0]@departure_airport, 1, ",") ; departure airport ID arrAir = str_get_field(f[0]@arrival_airport , 1, ",") ; arroval airport ID print("depAir="+depAir+" arrAir="+arrAir) print("---") ;---Graphics pltType = "x11" pltName = "O3_PM"+depAir+" nfil pltDir = "./" pltPath = pltDir + pltName wks = gsn_open_wks(pltType, pltPath) res = True res@xyExplicitLegendLabels = sprinti("%0.2i",ispan(0,nfili-1,1)) ; ispan(1,nfili,1) res@xyLineColors = (/"black","red", "green","blue","orange","yellow","gray","purple","magenta","orchid1","plum1","magenta4","pink1","maroon","lightpink4"/) res@xyDashPatterns = (/0, 5, 2, 1, 3, 2, 1, 5, 2, 0, 5, 2, 4, 2, 3/) res@xyLineThicknessF = 2 res@tiYAxisString = "O3_PM ppb" ;res@tiXAxisString = "Time" res@tiMainString = "Ozone to and fro Lagos Flights 2000" res@trYMinF = 10.0 res@trYMaxF = 200.0 res@pmLegendDisplayMode = "Always" res@pmLegendWidthF = 0.12 ;-- set legend width res@pmLegendHeightF = 0.19 ;-- set legend height res@pmLegendParallelPosF = 0.18 ;-- move legend right res@pmLegendOrthogonalPosF = 0.18 ;-- move legend up ;-- create plot time_sec = ispan(0,NTIM-1,1) time_sec@long_name = "seconds" plot = gsn_csm_xy(wks,time_sec,data,res)