From setareh.rahimi at gmail.com Sun Dec 10 08:00:25 2023 From: setareh.rahimi at gmail.com (Setareh Rahimi) Date: Sun, 10 Dec 2023 18:30:25 +0330 Subject: [ncl-talk] "Hourly " and "daily average precipitation" from WRF-Chem files Message-ID: Dear all, I need to calculate *hourly precipitation* from WRF-Chem output files. In order, to do this I used the below equation: (rainTot(nt,:,:) - rainTot(nt-1,:,:)) However, I received these error messages: fatal:Subscript out of range, error in subscript #0 fatal:An error occurred reading rainTot fatal:["Execute.c":8637]:Execute: Error occurred at or near line 70 in file precip Would you please advise me on how to remove these error messages? (the script is attached). I have also another question, how can I calculate the daily average precipitation, please? Many thanks in advance. Best wishes, -- S.Rahimi -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- begin f = addfile ("wrfout_d02_2021-01-28_00:00:00","r") rainc = f->RAINC ; (Time, south_north, west_east) rainnc = f->RAINNC u10 = f->U10 ; (Time, south_north, west_east) v10 = f->V10 times = wrf_user_getvar(f,"times",-1) ntim = dimsizes(times) ; # time steps ; ; Use NCL operator > to make sure all values >=0.0 ; Sum components and assign attributes ; rainc = rainc > 0.0 rainnc = rainnc > 0.0 rainTot = rainc + rainnc rainTot at description = "Total Precipitation" rainTot at units = rainc at units wks = gsn_open_wks("png","WRF_lc") colors = (/"white","azure" \ ,"green","palegreen","yellowgreen", "greenyellow" \ ,"yellow","goldenrod","orange","orangered" \ ,"red","deeppinK", "violet","darkviolet" \ ,"blueviolet","blue" /) res = True ; plot mods desired res at gsnMaximize = True ; maximize size res at gsnScalarContour = True ; contours desired res at gsnLeftString = "Wind Vectors (m/s)" res at gsnRightString = "Total Precipitation (mm)" res at cnFillOn = True ; color plot desired res at cnFillPalette = colors ; define colors for contour plot res at cnLinesOn = False ; turn off contour lines res at cnLineLabelsOn = False ; turn off contour labels res at cnFillMode = "RasterFill" ; raster res at cnLevelSelectionMode = "ExplicitLevels" ; explicit [unequal] cn levels res at cnLevels = (/0, 0.01,0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9,1 /) res at vcGlyphStyle = "WindBarb" res at vcRefLengthF = 0.025 ; ref vec length res at vcMinDistanceF = 0.025 ; larger means sparser res at vcWindBarbTickLengthF = 0.4 ; default 0.3 res at vcRefAnnoOn = False res = wrf_map_resources(f,res) res at gsnAddCyclic = False ; regional data: not cyclic res at tfDoNDCOverlay = True res at mpFillOn = False res at mpGeophysicalLineColor = "black" ; wrf_map_resources uses "gray" res at mpUSStateLineColor = "black" res at mpGeophysicalLineThicknessF = 2.0 ; wrf_map_resources uses 0.5 res at mpUSStateLineThicknessF = 2.0 ; ; Plot one time and level for demo ; . create u and v on a common grid for visualization: nothing fancy ; nt = 12 do nt=0,ntim-1 ; uncomment to loop res at tiMainString = times(nt) plot = gsn_csm_vector_scalar_map(wks,u10(nt,:,:),v10(nt,:,:),(rainTot(nt,:,:) - rainTot(nt-1,:,:)),res) end do end From dave.allured at noaa.gov Sun Dec 10 09:12:24 2023 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Sun, 10 Dec 2023 09:12:24 -0700 Subject: [ncl-talk] "Hourly " and "daily average precipitation" from WRF-Chem files In-Reply-To: References: Message-ID: Your code structure is: do nt=0,ntim-1 ... (rainTot(nt,:,:) - rainTot(nt-1,:,:)),res) end do So on the first iteration, nt = 0, and nt-1 = -1. That is a subscript out of bounds. What do you really want to compute here when nt=0? Do you want to skip this iteration? On Sun, Dec 10, 2023 at 7:57?AM Setareh Rahimi via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dear all, > > I need to calculate *hourly precipitation* from WRF-Chem output files. In > order, to do this I used the below equation: > (rainTot(nt,:,:) - rainTot(nt-1,:,:)) > > However, I received these error messages: > > fatal:Subscript out of range, error in subscript #0 > > fatal:An error occurred reading rainTot > > fatal:["Execute.c":8637]:Execute: Error occurred at or near line 70 in > file precip > > Would you please advise me on how to remove these error messages? (the > script is attached). > > I have also another question, how can I calculate the daily average > precipitation, please? > > Many thanks in advance. > > Best wishes, > -- > S.Rahimi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From setareh.rahimi at gmail.com Sun Dec 10 09:36:28 2023 From: setareh.rahimi at gmail.com (Setareh Rahimi) Date: Sun, 10 Dec 2023 20:06:28 +0330 Subject: [ncl-talk] "Hourly " and "daily average precipitation" from WRF-Chem files In-Reply-To: References: Message-ID: Dear Dave, Thank you so much for your reply. Yes! your are right, [nt-1 = -1] which is meaningless. I should skip this one, and set : do nt=1, ntim-1. I changed nt from 0 to 1 and it worked. Thanks! ******So I want to make sure that my calculation to achieve hourly precipitation is correct?***** _________________________________ *How about daily average precipitation, how can I calculate it, please?* On Sun, Dec 10, 2023 at 7:42?PM Dave Allured - NOAA Affiliate < dave.allured at noaa.gov> wrote: > Your code structure is: > > do nt=0,ntim-1 > ... (rainTot(nt,:,:) - rainTot(nt-1,:,:)),res) > > end do > > > So on the first iteration, nt = 0, and nt-1 = -1. That is a subscript out > of bounds. What do you really want to compute here when nt=0? Do you want > to skip this iteration? > > > On Sun, Dec 10, 2023 at 7:57?AM Setareh Rahimi via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Dear all, >> >> I need to calculate *hourly precipitation* from WRF-Chem output files. >> In order, to do this I used the below equation: >> (rainTot(nt,:,:) - rainTot(nt-1,:,:)) >> >> However, I received these error messages: >> >> fatal:Subscript out of range, error in subscript #0 >> >> fatal:An error occurred reading rainTot >> >> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 70 in >> file precip >> >> Would you please advise me on how to remove these error messages? (the >> script is attached). >> >> I have also another question, how can I calculate the daily average >> precipitation, please? >> >> Many thanks in advance. >> >> Best wishes, >> -- >> S.Rahimi >> > -- S.Rahimi -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.graffino at tim.it Fri Dec 15 05:31:31 2023 From: g.graffino at tim.it (Giorgio Graffino) Date: Fri, 15 Dec 2023 13:31:31 +0100 (CET) Subject: [ncl-talk] Read Matlab file and shift data longitudinally Message-ID: <4c0c893a.1dbc.18c6d75e358.Webtop.46@tim.it> Dear NCL experts, ? Hope you're all well. As per the subject, I want to read a .mat file containing daily SST data from 1940 to 2005 and run some analysis I've already written in NCL. If I try to directly read the file with NCL I get Segmentation fault, so that's not the right way to go. I converted the file into NetCDF using Matlab (https://uk.mathworks.com/help/matlab/import_export/exporting-to-network-common-data-form-netcdf-files.html?s_tid=answers_rc2-3_p6_MLT#bsxb70y-1), but there is a problem with the data.? ? At some point in the time series (around 1962), the data get shifted in the longitude sense by about 40 degrees. I checked this in NCL and in Ferret, as shown in the attached screenshot: the left-hand side is SST on a random day before 1962, while the right-hand side is after 1962. It's like there is an offset in the data longitudes. The plots are drawn using only four lines in Ferret, so the error can't be due to the the software. There must be something wrong going on when the file is created. It would be great to know what happens to the data in the first place, but maybe it's a discussion that doesn't belong here. ? This is the printVarSummary of the full data. The longitudes array does not change over time, but the data are shifted. ? Variable: temp Type: float Total Size: 710269560 bytes ? ? ? ? ? ?177567390 values Number of Dimensions: 3 Dimensions and sizes: ? [time | 24090] x [lats | 120] x [lons | 180] Coordinates:? ? ? ? ? ? ?time: [350616..929160] ? ? ? ? ? ?lats: [ -90..88.5] ? ? ? ? ? ?lons: [ ? 0.. 358] Number Of Attributes: 1 ?_FillValue : ?-9e+33 ? I'd like to know how I can correct the second part of the time series to make it like the first part. I tried with LonFlip and LonPivot but I couldn't make it work. I'm thinking about a way to shift the data back by that longitude offset, but I can't wrap my head around it. ? Please let me know. ? Cheers, Giorgio -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot_20231215_122717.png Type: image/png Size: 530593 bytes Desc: not available URL: From dave.allured at noaa.gov Fri Dec 15 08:32:17 2023 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Fri, 15 Dec 2023 08:32:17 -0700 Subject: [ncl-talk] Read Matlab file and shift data longitudinally In-Reply-To: <4c0c893a.1dbc.18c6d75e358.Webtop.46@tim.it> References: <4c0c893a.1dbc.18c6d75e358.Webtop.46@tim.it> Message-ID: Giorgio, I think you are right, there may be something wrong with the way the Netcdf file is created. Your link pointed to "Write Data to NetCDF File Using Low-Level Functions". Try using the Matlab high-level Netcdf export functions instead, such as *ncwrite*. Those do a better job of preserving dimensions and data alignment. It will be more constructive to debug your Matlab export process, than to try to manipulate a damaged data file. Check your work by comparing dimensions and data alignment with Matlab and Netcdf diagnostic functions. Dimensions before and after export should match exactly. Data samples at the same indices should match exactly. I find that NCL is convenient for examining small data samples, such as: print (temp(24089,20,0:3)) Matlab has something similar. On Fri, Dec 15, 2023 at 5:47?AM Giorgio Graffino via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dear NCL experts, > > > > Hope you're all well. As per the subject, I want to read a .mat file > containing daily SST data from 1940 to 2005 and run some analysis I've > already written in NCL. If I try to directly read the file with NCL I get > Segmentation fault, so that's not the right way to go. I converted the file > into NetCDF using Matlab ( > https://uk.mathworks.com/help/matlab/import_export/exporting-to-network-common-data-form-netcdf-files.html?s_tid=answers_rc2-3_p6_MLT#bsxb70y-1), > but there is a problem with the data. > > > > At some point in the time series (around 1962), the data get shifted in > the longitude sense by about 40 degrees. I checked this in NCL and in > Ferret, as shown in the attached screenshot: the left-hand side is SST on a > random day before 1962, while the right-hand side is after 1962. It's like > there is an offset in the data longitudes. The plots are drawn using only > four lines in Ferret, so the error can't be due to the the software. There > must be something wrong going on when the file is created. It would be > great to know what happens to the data in the first place, but maybe it's a > discussion that doesn't belong here. > > > > This is the printVarSummary of the full data. The longitudes array does > not change over time, but the data are shifted. > > > > Variable: temp > Type: float > Total Size: 710269560 bytes > 177567390 values > Number of Dimensions: 3 > Dimensions and sizes: [time | 24090] x [lats | 120] x [lons | 180] > Coordinates: > time: [350616..929160] > lats: [ -90..88.5] > lons: [ 0.. 358] > Number Of Attributes: 1 > _FillValue : -9e+33 > > > I'd like to know how I can correct the second part of the time series to > make it like the first part. I tried with LonFlip and LonPivot but I > couldn't make it work. I'm thinking about a way to shift the data back by > that longitude offset, but I can't wrap my head around it. > > > > Please let me know. > > Cheers, > > Giorgio > -------------- next part -------------- An HTML attachment was scrubbed... URL: From g.graffino at tim.it Mon Dec 18 03:10:52 2023 From: g.graffino at tim.it (Giorgio Graffino) Date: Mon, 18 Dec 2023 11:10:52 +0100 (CET) Subject: [ncl-talk] Read Matlab file and shift data longitudinally In-Reply-To: <4c0c893a.1dbc.18c6d75e358.Webtop.46@tim.it> References: <4c0c893a.1dbc.18c6d75e358.Webtop.46@tim.it> Message-ID: Hi Dave, ? Thanks for your reply. My first attempt at solving the problem was with ncwrite, but it was always giving me this error: ? Error using netcdflib The number of input elements does not match the variable size. ? This is why I had to use low-level functions. I did some research and found more functions to define dimensions and attributes, and now the data look all right. I'm attaching the script in case anyone needs it. ? Cheers, Giorgio ? ------ Messaggio Originale ------ Da: dave.allured at noaa.gov A: g.graffino at tim.it Cc: ncl-talk at ucar.edu Inviato: venerd?, dicembre 15? 2023, 04:32 PM Oggetto: Re: [ncl-talk] Read Matlab file and shift data longitudinally ? Giorgio, I think you are right, there may be something wrong with the way the Netcdf file is created.? Your link pointed to "Write Data to NetCDF File Using Low-Level Functions".? Try using the Matlab high-level Netcdf export functions instead, such as ncwrite.? Those do a better job of preserving dimensions and data alignment. ? It will be more constructive to debug your Matlab export process, than to try to manipulate a damaged data file.? Check your work by comparing dimensions and data alignment with Matlab and Netcdf diagnostic functions.? Dimensions before and after export should match exactly.? Data samples at the same indices should match exactly.? I find that NCL is convenient for examining small data samples, such as: ? ? ? print (temp(24089,20,0:3)) ? Matlab has something similar. ? ? On Fri, Dec 15, 2023 at 5:47?AM Giorgio Graffino via ncl-talk > wrote: ? Dear NCL experts, ? Hope you're all well. As per the subject, I want to read a .mat file containing daily SST data from 1940 to 2005 and run some analysis I've already written in NCL. If I try to directly read the file with NCL I get Segmentation fault, so that's not the right way to go. I converted the file into NetCDF using Matlab (https://uk.mathworks.com/help/matlab/import_export/exporting-to-network-common-data-form-netcdf-files.html?s_tid=answers_rc2-3_p6_MLT#bsxb70y-1 ), but there is a problem with the data.? ? At some point in the time series (around 1962), the data get shifted in the longitude sense by about 40 degrees. I checked this in NCL and in Ferret, as shown in the attached screenshot: the left-hand side is SST on a random day before 1962, while the right-hand side is after 1962. It's like there is an offset in the data longitudes. The plots are drawn using only four lines in Ferret, so the error can't be due to the the software. There must be something wrong going on when the file is created. It would be great to know what happens to the data in the first place, but maybe it's a discussion that doesn't belong here. ? This is the printVarSummary of the full data. The longitudes array does not change over time, but the data are shifted. ? Variable: temp Type: float Total Size: 710269560 bytes ? ? ? ? ? ?177567390 values Number of Dimensions: 3 Dimensions and sizes: ? [time | 24090] x [lats | 120] x [lons | 180] Coordinates:? ? ? ? ? ? ?time: [350616..929160] ? ? ? ? ? ?lats: [ -90..88.5] ? ? ? ? ? ?lons: [ ? 0.. 358] Number Of Attributes: 1 ?_FillValue : ?-9e+33 ? I'd like to know how I can correct the second part of the time series to make it like the first part. I tried with LonFlip and LonPivot but I couldn't make it work. I'm thinking about a way to shift the data back by that longitude offset, but I can't wrap my head around it. ? Please let me know. ?Cheers, Giorgio -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: MarcosCounterfactualSST.m Type: text/x-objcsrc Size: 1470 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot_20231215_200928.png Type: image/png Size: 580423 bytes Desc: not available URL: From Anieklal at cas.iitd.ac.in Tue Dec 19 07:52:26 2023 From: Anieklal at cas.iitd.ac.in (Anie K Lal) Date: Tue, 19 Dec 2023 20:22:26 +0530 Subject: [ncl-talk] Calculation of Cloud Liquid water path from WRF out file Message-ID: <1bdb444e0f40c8c9606a293899c2bb82@cas.iitd.ac.in> Hi all I am tring to get CLWP from WRF out file. I tried prcwater_dp as follows: q1 = f1->QCLOUD(:,:,:,:) ; kg/kg dp_a = wrf_user_getvar(f1,"p",-1) dp1 = dp_a(:,:,:,:) ; Pa q1!0 = "time" q1!1 = "lev" q1!2 = "lat" q1!3 = "lon" dp1!0 = "time" dp1!1 = "lev" dp1!2 = "lat" dp1!3 = "lon" lwp_a = prcwater_dp (q1(time|:,lat|:,lon|:,lev|:), dp1(time|:,lat|:,lon|:,lev|:)) ; kg/m2 Here I am getting values like 27.09562 45.50217 61.3766 68.90879 67.90661 66.62698 64.72494 67.85168 64.0595 62.04931 55.23169 42.21736 23.00407... in kg/m2 I also tried wrf_user_getvar(f1,"pw",-1). Here I am getting values like 5.871577 6.066606 6.3876 6.375202 6.273459 5.973719 6.050189 6.115168 6.225941 6.275452 6.347611 6.305155 6.381238 ... in kg/m2 But the realistic values are very small compared to what I am getting from previous literature: https://acp.copernicus.org/articles/20/5559/2020/ states values ~0-160 g/m2 https://acp.copernicus.org/articles/12/5583/2012/ staes values ~0-240 g/m2 and many examples are there. They all show clwp in g/m2 which is about 0-300 g/m2 range. So why I am getting very kigh values. Are the units in kg/m2 correct for the functions 'pw' and prcwater_dp. Looking forward to any kind of help. Thank you Anie -------------- next part -------------- An HTML attachment was scrubbed... URL: