From setareh.rahimi at gmail.com Thu Sep 14 05:25:29 2023 From: setareh.rahimi at gmail.com (Setareh Rahimi) Date: Thu, 14 Sep 2023 14:55:29 +0330 Subject: [ncl-install] error while using "calculate_daily_values() function" Message-ID: Dear all, I want to plot daily average dust from 5 bins of dust, on 30 pressure levels ( output from the WRF-Chem model). However, I face some errors that arise from the* calculate_daily_values() function. * Would you please kindly advise me to remove this issue? The errors and my script have been attached. Any suggestion is appreciated. Kind regards -- S.Rahimi -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl" ;*************************************************************************************************************************** f = addfile ("wrfout_d01_2011-06-22_00:00:00", "r") ;print(f) ; same as "nmcdump -h" Times = f->Times ; [Time | 41] x [DateStrLen | 19] (character) Time_0 = wrf_times_c( Times, 0 ) ; "hours since" initial time on file (double) ; Time_0 is recognized by cd_calendar Time_3 = wrf_times_c( Times, 3 ) ; yyyymmddhh (type "integer") Time_3 = Time_3/100 ; remove 'ss' part of Time_3 Time_3 at units = "yyyymmdd" ymd = cd_calendar(Time_0, -2) print(ymd) YMD = 20110630 print("********************************************************************************************************************") wks = gsn_open_wks("png" ,"WRF_dust_wind_Daily-Average"+YMD) ; ps,pdf,x11,ncgm,eps ;gsn_define_colormap(wks,"GMT_no_green") ; select color map res = True ; plot mods desired res at cnConstFEnableFill = True res at gsnMaximize = True res at gsnSpreadColors = True res at cnFillOn = True res at cnLinesOn = False res at cnLineLabelsOn = Fals WRF_map_c(f, res, 0) res at tfDoNDCOverlay = True ;********************************************************************************************************************* ;********************************************************************************************************************* ;res at cnLevelSelectionMode = "ExplicitLevels" ;res at cnLevels = (/0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2,2.1,2.2,2.3,2.4,2.5/) res at mpFillOn = False res at mpLimitMode = "LatLon" ; choose region of map res at mpDataBaseVersion = "MediumRes" ; better map outlines res at pmTickMarkDisplayMode= "Always" ; turn on tickmarks res at pmTickMarkDisplayMode = "Always" res at mpMaxLatF = 40 ; choose subregion res at mpMinLatF = 24 res at mpMaxLonF = 63 res at mpMinLonF = 44 ;*************************************************************************************************************************** ;ymd = cd_calendar(Time_0, -2) ;print(ymd) ;YMD = 20110705 mt = ind(YMD.eq.ymd) A1 = f->DUST_1 ; (Time, south_north, west_east) A1&Time = Time_0 ; associate the 'Time' coordinate with the variable using standard NCL & syntax a1 = A1(mt,:,:,:) ; (Time, south_north, west_east) printVarSummary(a1) ; [Time | 8] x [bottom_top | 35] x [south_north | 199] x [west_east | 199] ;*************************************************************************************************************************** A2 =f->DUST_2 A2&Time = Time_0 a2 = A2(mt,:,:,:) A3 =f->DUST_3 A3&Time = Time_0 a3 = A3(mt,:,:,:) A4 =f->DUST_4 A4&Time = Time_0 a4 = A4(mt,:,:,:) A5 =f->DUST_5 A5&Time = Time_0 a5 = A5(mt,:,:,:) ;*************************************************************************************************************************** time_3 = Time_3(mt) ; (Time | 8) print(time_3) ;*************************************************************************************************************************** at= a1+a2+a3+a4+a5 ;sum over all 5 dust bin sizes to get total dust concentration at at time = "Time" at at long_name = "Total dust" at at description = "Total dust from 5 bin dust sizes" at!0 = "time" at&time = Time_3(mt) if (any(isnan_ieee(at))) then value = 9.96921e+36 replace_ieeenan (at,value,0) at at _FillValue = value end if printVarSummary(at) print("********************************************************************************************************************") opt_cdv = True ; option for calculate_daily_values (cdv) opt_cdv at nval_crit = 4 ; default is 1 Day = calculate_daily_values (at, "avg", 0, opt_cdv) printVarSummary(Day) ; [Time | 1] x [bottom_top | 35] x [south_north | 199] x [west_east | 199] printMinMax (Day,1) print(Day) dd = dim_sum_n_Wrap( Day(:,0:34,:,:), 1) printVarSummary(dd) ;print(dd) print("") print("***********************************************************************************************************") print("***********************************************************************************************************") print("") res at tiMainString = "DUST- " + time_3(0) plot = gsn_csm_contour_map(wks,dd(0,:,:),res) shapefile_name1 = "world-administrative-boundaries.shp" shapefile_name2 = "gadm36_IRN_0.shp" lnres = True lnres at gsLineThicknessF = 3.0 lnres at gsLineColor = "Black" shape1 = gsn_add_shapefile_polylines(wks,plot,shapefile_name1,lnres) shape2 = gsn_add_shapefile_polylines(wks,plot,shapefile_name2,lnres) res at gsnDraw = False res at gsnFrame= False draw(plot) frame(wks) -------------- next part -------------- A non-text attachment was scrubbed... Name: Screen Shot 1402-06-23 at 14.52.36.png Type: image/png Size: 115701 bytes Desc: not available URL: From asphilli at ucar.edu Mon Sep 18 10:09:35 2023 From: asphilli at ucar.edu (Adam Phillips) Date: Mon, 18 Sep 2023 10:09:35 -0600 Subject: [ncl-install] error while using "calculate_daily_values() function" In-Reply-To: References: Message-ID: Hi Setareh, For general NCL questions you should post to the ncl-talk email list. This email list is for NCL installation questions. Note though that traffic on both lists has seriously dropped off the past couple of years. I think your problem is due to the time of your "at" array not being able to be converted by cd_calendar (as you have already converted it). The time array included as a coordinate variable in the array passed to calculate_daily_values must be able to be converted by cd_calendar as is noted in the documentation . Try switching this line that assigns the cd_calendar converted time array: at&time = Time_3(mt) to this that assigns the array converted by wrf_times_c: at&time = Time_0(mt) As always, verify that the fix works for your situation as I cannot test the script. Good luck! Adam On Thu, Sep 14, 2023 at 5:25?AM Setareh Rahimi via ncl-install < ncl-install at mailman.ucar.edu> wrote: > Dear all, > I want to plot daily average dust from 5 bins of dust, on 30 pressure > levels ( output from the WRF-Chem model). However, I face some errors that > arise from the* calculate_daily_values() function. * > Would you please kindly advise me to remove this issue? > The errors and my script have been attached. > Any suggestion is appreciated. > Kind regards > -- > S.Rahimi > > _______________________________________________ > ncl-install mailing list > List instructions, subscriber options, unsubscribe: > https://mailman.ucar.edu/mailman/listinfo/ncl-install > -- Adam Phillips Associate Scientist IV, Climate Analysis Section Climate and Global Dynamics Laboratory National Center for Atmospheric Research www.cgd.ucar.edu/staff/asphilli/ -------------- next part -------------- An HTML attachment was scrubbed... URL: