From olagueralyndonmark429 at gmail.com Tue Aug 8 22:51:00 2023 From: olagueralyndonmark429 at gmail.com (Lyndz) Date: Wed, 9 Aug 2023 12:51:00 +0800 Subject: [ncl-talk] problem with specx_anal (ntim x nlat x nlon) Message-ID: Dear NCL-experts, I would like to do a spectral analysis on a *ntim x nlat x lon* data as indicated in example 3 from this page: https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml *Specifically, I would like to get the mean spectra so that the final output will have meanspectra x lat x lon* *So far, I have the following:* ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open netcdf file rain = ufile->rAnom_sm(:,:,:) printVarSummary(rain) ;[time | 6954] x [latitude | 220] x [longitude | 220] d = 0 sm = 1 ; periodogram pct = 0.10 ;************************************************ ; calculate mean spectrum spectrum and lag1 auto cor ;************************************************ ntim = 6954 nlat = 220 nlon = 220 nseg = 49 nlen = ntim/nseg spcavg = new (ntim/141, typeof(rain)) printVarSummary(spcavg) spcavg = new ( ntim/2, typeof(rain)) spcavg = 0.0 r1zsum = 0.0 do n=0,nseg-1 dof = specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; current segment spc spcavg = spcavg + dof at spcx ; sum spc of each segment r1 = dof at xlag1 ; extract segment lag-1 r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z end do r1z = r1zsum/nseg ; average r1z r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back ; this is the mean r1 spcavg = spcavg/nseg ; average spectrum *Questions:* (1) How do I loop this across all the gridpoints? I am having a problem with the looping and saving the spectra in spcavg(ntim,nlat,nlon). Any suggestions on how to do this in NCL? The example in the page is incomplete. I'll appreciate any help on this. -Lyndz -------------- next part -------------- An HTML attachment was scrubbed... URL: From olagueralyndonmark429 at gmail.com Wed Aug 9 01:00:58 2023 From: olagueralyndonmark429 at gmail.com (Lyndz) Date: Wed, 9 Aug 2023 15:00:58 +0800 Subject: [ncl-talk] Fwd: problem with specx_anal (ntim x nlat x nlon) In-Reply-To: References: Message-ID: Dear NCL-experts, Just a follow up on my post earlier. I tried the following: ;************************************************ ; calculate mean spectrum spectrum and lag1 auto cor ;************************************************ ntim = 6954 nlat = 220 nlon = 220 nseg = 49 nlen = ntim/nseg minlat = -14.875 maxlat = 39.875 minlon = 90.125 maxlon = 144.875 spcavg = onedtond(rain,(/nseg,nlat,nlon/)) printVarSummary(spcavg) spcavg = 0.0 r1zsum = 0.0 dm = 1 sm = 1 pct = 0.10 r1zsum = 0.0 mlon=220 nlat=220 do nl=0,nlat-1 do ml=0,mlon-1 do n=0,nseg-1 dof = specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; current segment spc spcavg = spcavg + dof at spcx ; sum spc of each segment r1 = dof at xlag1 ; extract segment lag-1 r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z end do end do ; ml end do ; nl It gives the following error: ncl 64> do nl=0,nlat-1 ncl 65> do ml=0,mlon-1 ncl 66> do n=0,nseg-1 ncl 67> dof = specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; current segment spc ncl 68> spcavg = spcavg + dof at spcx ; sum spc of each segment ncl 69> r1 = dof at xlag1 ; extract segment lag-1 ncl 70> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z ncl 71> end do ncl 72> end do ; ml ncl 73> end do ; nl *fatal:Number of dimensions in parameter (0) of (specx_anal) is (3), (1) dimensions were expected fatal:["Execute.c":8635]:Execute: Error occurred at or near line 67* Any suggestion on how to do this correctly in NCL? -Lyndz --------------------------------------------------------------------- Dear NCL-experts, I would like to do a spectral analysis on a *ntim x nlat x lon* data as indicated in example 3 from this page: https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml *Specifically, I would like to get the mean spectra so that the final output will have meanspectra x lat x lon* *So far, I have the following:* ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open netcdf file rain = ufile->rAnom_sm(:,:,:) printVarSummary(rain) ;[time | 6954] x [latitude | 220] x [longitude | 220] d = 0 sm = 1 ; periodogram pct = 0.10 ;************************************************ ; calculate mean spectrum spectrum and lag1 auto cor ;************************************************ ntim = 6954 nlat = 220 nlon = 220 nseg = 49 nlen = ntim/nseg spcavg = new (ntim/141, typeof(rain)) printVarSummary(spcavg) spcavg = new ( ntim/2, typeof(rain)) spcavg = 0.0 r1zsum = 0.0 do n=0,nseg-1 dof = specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; current segment spc spcavg = spcavg + dof at spcx ; sum spc of each segment r1 = dof at xlag1 ; extract segment lag-1 r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z end do r1z = r1zsum/nseg ; average r1z r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back ; this is the mean r1 spcavg = spcavg/nseg ; average spectrum *Questions:* (1) How do I loop this across all the gridpoints? I am having a problem with the looping and saving the spectra in spcavg(ntim,nlat,nlon). Any suggestions on how to do this in NCL? The example in the page is incomplete. I'll appreciate any help on this. -Lyndz -------------- next part -------------- An HTML attachment was scrubbed... URL: From rashidcomsis at gmail.com Wed Aug 9 03:13:04 2023 From: rashidcomsis at gmail.com (Rashed Mahmood) Date: Wed, 9 Aug 2023 11:13:04 +0200 Subject: [ncl-talk] Fwd: problem with specx_anal (ntim x nlat x nlon) In-Reply-To: References: Message-ID: Hi Lyndz, There are several problems with your code. I do not have time to explain these issues but you can compare the two codes to see the differences. The below code should work, however, you need to think about what output you are expecting and do testing of the results. I am not an expert on spectral analysis so you will need to make sure if the results are as expected. begin ntim = 6954 nlat = 220 nlon = 220 ;rain = random_normal(6.5,19.8,(/ntim,nlat,nlon/)) nseg = 49 nlen = ntim/nseg minlat = -14.875 maxlat = 39.875 minlon = 90.125 maxlon = 144.875 spcavgFin = new((/nlen/2,nlat,nlon/),float) ;onedtond(rain,(/nseg,nlat,nlon/)) r1zsumFin = new((/nlat,nlon/),float) printVarSummary(spcavgFin) dm = 1 sm = 1 pct = 0.10 ;r1zsum = 0.0 mlon=220 nlat=220 do nl=0,nlat-1 do ml=0,mlon-1 r1zsum =0. spcavg =new(nlen/2,float) spcavg =0. do n=0,nseg-1 ;print(n+"") ;dof = specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; current segment spc dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) ; assuming rain has dims as: (time, lat, lon) spcavg = spcavg + dof at spcx ; sum spc of each segment r1 = dof at xlag1 ; extract segment lag-1 r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z end do r1z = r1zsum/nseg ; average r1z r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back r1zsumFin(nl,ml) = r1 ; this is the mean r1 spcavgFin(:,nl,ml) = spcavg/nseg ; average spectrum delete([/r1z,r1/]) end do ; ml end do ; nl end Good luck. Rashed On Wed, Aug 9, 2023 at 9:16?AM Lyndz via ncl-talk wrote: > Dear NCL-experts, > > Just a follow up on my post earlier. > > I tried the following: > > > ;************************************************ > ; calculate mean spectrum spectrum and lag1 auto cor > ;************************************************ > > ntim = 6954 > nlat = 220 > nlon = 220 > nseg = 49 > nlen = ntim/nseg > minlat = -14.875 > maxlat = 39.875 > minlon = 90.125 > maxlon = 144.875 > spcavg = onedtond(rain,(/nseg,nlat,nlon/)) > printVarSummary(spcavg) > spcavg = 0.0 > r1zsum = 0.0 > > dm = 1 > sm = 1 > pct = 0.10 > r1zsum = 0.0 > > mlon=220 > nlat=220 > > do nl=0,nlat-1 > do ml=0,mlon-1 > do n=0,nseg-1 > dof = > specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; > current segment spc > spcavg = spcavg + dof at spcx ; sum spc of each segment > r1 = dof at xlag1 ; extract segment lag-1 > r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z > end do > end do ; ml > end do ; nl > > > It gives the following error: > > ncl 64> do nl=0,nlat-1 > ncl 65> do ml=0,mlon-1 > ncl 66> do n=0,nseg-1 > ncl 67> dof = > specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; > current segment spc > ncl 68> spcavg = spcavg + dof at spcx ; sum spc of > each segment > ncl 69> r1 = dof at xlag1 ; extract > segment lag-1 > ncl 70> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the > Fischer Z > ncl 71> end do > ncl 72> end do ; ml > ncl 73> end do ; nl > > > *fatal:Number of dimensions in parameter (0) of (specx_anal) is (3), (1) > dimensions were expected fatal:["Execute.c":8635]:Execute: Error occurred > at or near line 67* > > > Any suggestion on how to do this correctly in NCL? > > -Lyndz > > > > > > > > > > > > > --------------------------------------------------------------------- > > Dear NCL-experts, > > I would like to do a spectral analysis on a *ntim x nlat x lon* data as > indicated in example 3 from this page: > https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml > > *Specifically, I would like to get the mean spectra so that the final > output will have meanspectra x lat x lon* > > > *So far, I have the following:* > > ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open > netcdf file > rain = ufile->rAnom_sm(:,:,:) > > printVarSummary(rain) ;[time | 6954] x [latitude | 220] x > [longitude | 220] > > d = 0 > sm = 1 ; periodogram > pct = 0.10 > > > ;************************************************ > ; calculate mean spectrum spectrum and lag1 auto cor > ;************************************************ > > ntim = 6954 > nlat = 220 > nlon = 220 > > nseg = 49 > nlen = ntim/nseg > > spcavg = new (ntim/141, typeof(rain)) > printVarSummary(spcavg) > spcavg = new ( ntim/2, typeof(rain)) > spcavg = 0.0 > r1zsum = 0.0 > > do n=0,nseg-1 > dof = > specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; > current segment spc > spcavg = spcavg + dof at spcx ; sum spc of each segment > r1 = dof at xlag1 ; extract segment lag-1 > r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z > end do > r1z = r1zsum/nseg ; average r1z > r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back > ; > this is the mean r1 > spcavg = spcavg/nseg ; average spectrum > > *Questions:* > (1) How do I loop this across all the gridpoints? I am having a problem > with the looping and saving the spectra in spcavg(ntim,nlat,nlon). Any > suggestions on how to do this in NCL? The example in the page is incomplete. > > > I'll appreciate any help on this. > > > -Lyndz > > > > > _______________________________________________ > ncl-talk mailing list > ncl-talk at mailman.ucar.edu > List instructions, subscriber options, unsubscribe: > https://mailman.ucar.edu/mailman/listinfo/ncl-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olagueralyndonmark429 at gmail.com Thu Aug 10 01:31:27 2023 From: olagueralyndonmark429 at gmail.com (Lyndz) Date: Thu, 10 Aug 2023 15:31:27 +0800 Subject: [ncl-talk] Fwd: problem with specx_anal (ntim x nlat x nlon) In-Reply-To: References: Message-ID: Dear Rashed, NCL-experts, Many thanks for this. My goal is actually to plot the fractional variance as a map after getting the mean spectra, Something like this, which I can get from the average spectra: 5-to-10day variance: var_510 = SUM{*spcx*('f5->f10')*df} fractional_variance = var_510/total_variance Attached is the modified script following your suggestion and I got this error: fatal:specx_anal: 'x' cannot contain any missing values fatal:["Execute.c":8637]:Execute: Error occurred at or near line 69 in file spectral_analysis.ncl Im using the Aphrodite rainfall data set with missing values over the ocean and some landpoints. spectral analysis cannot be applied to time series with missing values. To remove this error, I set: rain at _FillValue = 0.0 delete(rain at _FillValue) *Is there another way to avoid this? Like ignore the gridpoints with missing values and the input/output will still have the 3D dimension?* If I do something like this at the beginning, the input is no longer 3D. p1 = ndtooned( rain ) i = ind(.not.ismissing(p1)) ; all non-missing values if (.not.all(ismissing(i))) then rainNew = p1(i) ; rainNew is 1D copy_VarAtts (rain, rainNew) ; copy attributes else print("No missing values") end if --Lynz On Wed, Aug 9, 2023 at 5:13?PM Rashed Mahmood wrote: > Hi Lyndz, > There are several problems with your code. I do not have time to explain > these issues but you can compare the two codes to see the differences. The > below code should work, however, you need to think about what output you > are expecting and do testing of the results. I am not an expert on spectral > analysis so you will need to make sure if the results are as expected. > > > begin > ntim = 6954 > nlat = 220 > nlon = 220 > ;rain = random_normal(6.5,19.8,(/ntim,nlat,nlon/)) > nseg = 49 > nlen = ntim/nseg > minlat = -14.875 > maxlat = 39.875 > minlon = 90.125 > maxlon = 144.875 > spcavgFin = new((/nlen/2,nlat,nlon/),float) > ;onedtond(rain,(/nseg,nlat,nlon/)) > r1zsumFin = new((/nlat,nlon/),float) > printVarSummary(spcavgFin) > dm = 1 > sm = 1 > pct = 0.10 > ;r1zsum = 0.0 > > mlon=220 > nlat=220 > do nl=0,nlat-1 > do ml=0,mlon-1 > r1zsum =0. > spcavg =new(nlen/2,float) > spcavg =0. > do n=0,nseg-1 > ;print(n+"") > ;dof = > specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; > current segment spc > dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) ; > assuming rain has dims as: (time, lat, lon) > spcavg = spcavg + dof at spcx ; sum spc of each segment > r1 = dof at xlag1 ; extract segment lag-1 > r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z > end do > r1z = r1zsum/nseg ; average r1z > r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back > r1zsumFin(nl,ml) = r1 ; this is the mean r1 > spcavgFin(:,nl,ml) = spcavg/nseg ; average spectrum > delete([/r1z,r1/]) > end do ; ml > end do ; nl > end > > Good luck. > Rashed > > > On Wed, Aug 9, 2023 at 9:16?AM Lyndz via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Dear NCL-experts, >> >> Just a follow up on my post earlier. >> >> I tried the following: >> >> >> ;************************************************ >> ; calculate mean spectrum spectrum and lag1 auto cor >> ;************************************************ >> >> ntim = 6954 >> nlat = 220 >> nlon = 220 >> nseg = 49 >> nlen = ntim/nseg >> minlat = -14.875 >> maxlat = 39.875 >> minlon = 90.125 >> maxlon = 144.875 >> spcavg = onedtond(rain,(/nseg,nlat,nlon/)) >> printVarSummary(spcavg) >> spcavg = 0.0 >> r1zsum = 0.0 >> >> dm = 1 >> sm = 1 >> pct = 0.10 >> r1zsum = 0.0 >> >> mlon=220 >> nlat=220 >> >> do nl=0,nlat-1 >> do ml=0,mlon-1 >> do n=0,nseg-1 >> dof = >> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >> current segment spc >> spcavg = spcavg + dof at spcx ; sum spc of each >> segment >> r1 = dof at xlag1 ; extract segment lag-1 >> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >> end do >> end do ; ml >> end do ; nl >> >> >> It gives the following error: >> >> ncl 64> do nl=0,nlat-1 >> ncl 65> do ml=0,mlon-1 >> ncl 66> do n=0,nseg-1 >> ncl 67> dof = >> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >> current segment spc >> ncl 68> spcavg = spcavg + dof at spcx ; sum spc of >> each segment >> ncl 69> r1 = dof at xlag1 ; extract >> segment lag-1 >> ncl 70> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the >> Fischer Z >> ncl 71> end do >> ncl 72> end do ; ml >> ncl 73> end do ; nl >> >> >> *fatal:Number of dimensions in parameter (0) of (specx_anal) is (3), (1) >> dimensions were expected fatal:["Execute.c":8635]:Execute: Error occurred >> at or near line 67* >> >> >> Any suggestion on how to do this correctly in NCL? >> >> -Lyndz >> >> >> >> >> >> >> >> >> >> >> >> >> --------------------------------------------------------------------- >> >> Dear NCL-experts, >> >> I would like to do a spectral analysis on a *ntim x nlat x lon* data as >> indicated in example 3 from this page: >> https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml >> >> *Specifically, I would like to get the mean spectra so that the final >> output will have meanspectra x lat x lon* >> >> >> *So far, I have the following:* >> >> ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open >> netcdf file >> rain = ufile->rAnom_sm(:,:,:) >> >> printVarSummary(rain) ;[time | 6954] x [latitude | 220] x >> [longitude | 220] >> >> d = 0 >> sm = 1 ; periodogram >> pct = 0.10 >> >> >> ;************************************************ >> ; calculate mean spectrum spectrum and lag1 auto cor >> ;************************************************ >> >> ntim = 6954 >> nlat = 220 >> nlon = 220 >> >> nseg = 49 >> nlen = ntim/nseg >> >> spcavg = new (ntim/141, typeof(rain)) >> printVarSummary(spcavg) >> spcavg = new ( ntim/2, typeof(rain)) >> spcavg = 0.0 >> r1zsum = 0.0 >> >> do n=0,nseg-1 >> dof = >> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >> current segment spc >> spcavg = spcavg + dof at spcx ; sum spc of each segment >> r1 = dof at xlag1 ; extract segment lag-1 >> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z >> end do >> r1z = r1zsum/nseg ; average r1z >> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >> ; >> this is the mean r1 >> spcavg = spcavg/nseg ; average spectrum >> >> *Questions:* >> (1) How do I loop this across all the gridpoints? I am having a problem >> with the looping and saving the spectra in spcavg(ntim,nlat,nlon). Any >> suggestions on how to do this in NCL? The example in the page is incomplete. >> >> >> I'll appreciate any help on this. >> >> >> -Lyndz >> >> >> >> >> _______________________________________________ >> ncl-talk mailing list >> ncl-talk at mailman.ucar.edu >> List instructions, subscriber options, unsubscribe: >> https://mailman.ucar.edu/mailman/listinfo/ncl-talk >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: spectral_analysis.ncl Type: application/octet-stream Size: 2246 bytes Desc: not available URL: From shea at ucar.edu Thu Aug 10 19:24:32 2023 From: shea at ucar.edu (Dennis Shea) Date: Thu, 10 Aug 2023 19:24:32 -0600 Subject: [ncl-talk] Fwd: problem with specx_anal (ntim x nlat x nlon) In-Reply-To: References: Message-ID: [1] The spectral analysis function uses an FFT. Missing values [_FillValue] are not allowed. [2] You should *never* substitute a value [say, 0.0] for missing values. You will get numbers returned but they are *not* the correct numbers. Value substitution creates an erroneous spectrum. [3] My recollection of the way NCL executes the *specx_anal* * function *is [a] the *time series for* *each individual grid point *is examined prior to invoking the FFT [b] If the grid point time series contains one or more missing values, an error counter is incremented: ERR=ERR+1 [c] If no missing values are present, the spectral information for that grid point is computed. [d] *after* looping through all the grid points, if 'ERR' is non zero, the error message is issued to the user BUT the grid points with no _FillValue should have useable numbers. Good Luck ========== %> less $NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl On Thu, Aug 10, 2023 at 1:47?AM Lyndz via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dear Rashed, NCL-experts, > > Many thanks for this. > My goal is actually to plot the fractional variance as a map after getting > the mean spectra, > Something like this, which I can get from the average spectra: > > 5-to-10day variance: var_510 = SUM{*spcx*('f5->f10')*df} > > fractional_variance = var_510/total_variance > > Attached is the modified script following your suggestion and I got this > error: > fatal:specx_anal: 'x' cannot contain any missing values > fatal:["Execute.c":8637]:Execute: Error occurred at or near line 69 in > file spectral_analysis.ncl > > Im using the Aphrodite rainfall data set with missing values over the > ocean and some landpoints. spectral analysis cannot be applied to time > series with missing values. > To remove this error, I set: > > rain at _FillValue = 0.0 > delete(rain at _FillValue) > > > *Is there another way to avoid this? Like ignore the gridpoints with > missing values and the input/output will still have the 3D dimension?* > > If I do something like this at the beginning, the input is no longer 3D. > > p1 = ndtooned( rain ) > i = ind(.not.ismissing(p1)) ; all non-missing values > if (.not.all(ismissing(i))) then > rainNew = p1(i) ; rainNew is 1D > copy_VarAtts (rain, rainNew) ; copy attributes > else > print("No missing values") > end if > > --Lynz > > > > > On Wed, Aug 9, 2023 at 5:13?PM Rashed Mahmood > wrote: > >> Hi Lyndz, >> There are several problems with your code. I do not have time to explain >> these issues but you can compare the two codes to see the differences. The >> below code should work, however, you need to think about what output you >> are expecting and do testing of the results. I am not an expert on spectral >> analysis so you will need to make sure if the results are as expected. >> >> >> begin >> ntim = 6954 >> nlat = 220 >> nlon = 220 >> ;rain = random_normal(6.5,19.8,(/ntim,nlat,nlon/)) >> nseg = 49 >> nlen = ntim/nseg >> minlat = -14.875 >> maxlat = 39.875 >> minlon = 90.125 >> maxlon = 144.875 >> spcavgFin = new((/nlen/2,nlat,nlon/),float) >> ;onedtond(rain,(/nseg,nlat,nlon/)) >> r1zsumFin = new((/nlat,nlon/),float) >> printVarSummary(spcavgFin) >> dm = 1 >> sm = 1 >> pct = 0.10 >> ;r1zsum = 0.0 >> >> mlon=220 >> nlat=220 >> do nl=0,nlat-1 >> do ml=0,mlon-1 >> r1zsum =0. >> spcavg =new(nlen/2,float) >> spcavg =0. >> do n=0,nseg-1 >> ;print(n+"") >> ;dof = >> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >> current segment spc >> dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) ; >> assuming rain has dims as: (time, lat, lon) >> spcavg = spcavg + dof at spcx ; sum spc of each >> segment >> r1 = dof at xlag1 ; extract segment lag-1 >> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >> end do >> r1z = r1zsum/nseg ; average r1z >> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >> r1zsumFin(nl,ml) = r1 ; this is the mean r1 >> spcavgFin(:,nl,ml) = spcavg/nseg ; average spectrum >> delete([/r1z,r1/]) >> end do ; ml >> end do ; nl >> end >> >> Good luck. >> Rashed >> >> >> On Wed, Aug 9, 2023 at 9:16?AM Lyndz via ncl-talk < >> ncl-talk at mailman.ucar.edu> wrote: >> >>> Dear NCL-experts, >>> >>> Just a follow up on my post earlier. >>> >>> I tried the following: >>> >>> >>> ;************************************************ >>> ; calculate mean spectrum spectrum and lag1 auto cor >>> ;************************************************ >>> >>> ntim = 6954 >>> nlat = 220 >>> nlon = 220 >>> nseg = 49 >>> nlen = ntim/nseg >>> minlat = -14.875 >>> maxlat = 39.875 >>> minlon = 90.125 >>> maxlon = 144.875 >>> spcavg = onedtond(rain,(/nseg,nlat,nlon/)) >>> printVarSummary(spcavg) >>> spcavg = 0.0 >>> r1zsum = 0.0 >>> >>> dm = 1 >>> sm = 1 >>> pct = 0.10 >>> r1zsum = 0.0 >>> >>> mlon=220 >>> nlat=220 >>> >>> do nl=0,nlat-1 >>> do ml=0,mlon-1 >>> do n=0,nseg-1 >>> dof = >>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>> current segment spc >>> spcavg = spcavg + dof at spcx ; sum spc of each >>> segment >>> r1 = dof at xlag1 ; extract segment lag-1 >>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >>> end do >>> end do ; ml >>> end do ; nl >>> >>> >>> It gives the following error: >>> >>> ncl 64> do nl=0,nlat-1 >>> ncl 65> do ml=0,mlon-1 >>> ncl 66> do n=0,nseg-1 >>> ncl 67> dof = >>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>> current segment spc >>> ncl 68> spcavg = spcavg + dof at spcx ; sum spc of >>> each segment >>> ncl 69> r1 = dof at xlag1 ; extract >>> segment lag-1 >>> ncl 70> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the >>> Fischer Z >>> ncl 71> end do >>> ncl 72> end do ; ml >>> ncl 73> end do ; nl >>> >>> >>> *fatal:Number of dimensions in parameter (0) of (specx_anal) is (3), (1) >>> dimensions were expected fatal:["Execute.c":8635]:Execute: Error occurred >>> at or near line 67* >>> >>> >>> Any suggestion on how to do this correctly in NCL? >>> >>> -Lyndz >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> --------------------------------------------------------------------- >>> >>> Dear NCL-experts, >>> >>> I would like to do a spectral analysis on a *ntim x nlat x lon* data as >>> indicated in example 3 from this page: >>> https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml >>> >>> *Specifically, I would like to get the mean spectra so that the final >>> output will have meanspectra x lat x lon* >>> >>> >>> *So far, I have the following:* >>> >>> ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open >>> netcdf file >>> rain = ufile->rAnom_sm(:,:,:) >>> >>> printVarSummary(rain) ;[time | 6954] x [latitude | 220] x >>> [longitude | 220] >>> >>> d = 0 >>> sm = 1 ; periodogram >>> pct = 0.10 >>> >>> >>> ;************************************************ >>> ; calculate mean spectrum spectrum and lag1 auto cor >>> ;************************************************ >>> >>> ntim = 6954 >>> nlat = 220 >>> nlon = 220 >>> >>> nseg = 49 >>> nlen = ntim/nseg >>> >>> spcavg = new (ntim/141, typeof(rain)) >>> printVarSummary(spcavg) >>> spcavg = new ( ntim/2, typeof(rain)) >>> spcavg = 0.0 >>> r1zsum = 0.0 >>> >>> do n=0,nseg-1 >>> dof = >>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>> current segment spc >>> spcavg = spcavg + dof at spcx ; sum spc of each >>> segment >>> r1 = dof at xlag1 ; extract segment lag-1 >>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z >>> end do >>> r1z = r1zsum/nseg ; average r1z >>> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >>> >>> ; this is the mean r1 >>> spcavg = spcavg/nseg ; average >>> spectrum >>> >>> *Questions:* >>> (1) How do I loop this across all the gridpoints? I am having a problem >>> with the looping and saving the spectra in spcavg(ntim,nlat,nlon). Any >>> suggestions on how to do this in NCL? The example in the page is incomplete. >>> >>> >>> I'll appreciate any help on this. >>> >>> >>> -Lyndz >>> >>> >>> >>> >>> _______________________________________________ >>> ncl-talk mailing list >>> ncl-talk at mailman.ucar.edu >>> List instructions, subscriber options, unsubscribe: >>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk >>> >> _______________________________________________ > ncl-talk mailing list > ncl-talk at mailman.ucar.edu > List instructions, subscriber options, unsubscribe: > https://mailman.ucar.edu/mailman/listinfo/ncl-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From olagueralyndonmark429 at gmail.com Thu Aug 10 20:16:18 2023 From: olagueralyndonmark429 at gmail.com (Lyndz) Date: Fri, 11 Aug 2023 10:16:18 +0800 Subject: [ncl-talk] Fwd: problem with specx_anal (ntim x nlat x nlon) In-Reply-To: References: Message-ID: Dear Sir Dennis, NCL-experts. Thank you for this valuable information! Do you have any suggestions on how to solve this issue? *fatal:specx_anal: 'x' cannot contain any missing valuesfatal:["Execute.c":8637]:Execute: Error occurred at or near line 69 in file spectral_analysis.ncl* *from this line:* dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) ; assuming rain has dims as: (time, lat, lon) I checked the diagnostic functions from the MJO page( https://www.ncl.ucar.edu/Document/Functions/Diagnostics/index.shtml). The closest one that I was trying to do is using the mjo_spectra_season . But this one is for area averaged spectra. I would like to do the spectral analysis for all grid points with valid values. Thank you for all the help. Sincerely, Lyndz On Fri, Aug 11, 2023 at 9:24?AM Dennis Shea wrote: > [1] The spectral analysis function uses an FFT. Missing values > [_FillValue] are not allowed. > [2] You should *never* substitute a value [say, 0.0] for missing values. > You will get numbers returned but they are *not* the correct numbers. Value > substitution creates an erroneous spectrum. > [3] My recollection of the way NCL executes the *specx_anal* > * > function *is > [a] the *time series for* *each individual grid point *is examined > prior to invoking the FFT > [b] If the grid point time series contains one or more missing > values, an error counter is incremented: ERR=ERR+1 > [c] If no missing values are present, the spectral information for > that grid point is computed. > [d] *after* looping through all the grid points, if 'ERR' is non > zero, the error message is issued to the user BUT the grid points with no > _FillValue should have useable numbers. > > Good Luck > ========== > > > > > > > %> less $NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl > > > On Thu, Aug 10, 2023 at 1:47?AM Lyndz via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Dear Rashed, NCL-experts, >> >> Many thanks for this. >> My goal is actually to plot the fractional variance as a map after >> getting the mean spectra, >> Something like this, which I can get from the average spectra: >> >> 5-to-10day variance: var_510 = SUM{*spcx*('f5->f10')*df} >> >> fractional_variance = var_510/total_variance >> >> Attached is the modified script following your suggestion and I got this >> error: >> fatal:specx_anal: 'x' cannot contain any missing values >> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 69 in >> file spectral_analysis.ncl >> >> Im using the Aphrodite rainfall data set with missing values over the >> ocean and some landpoints. spectral analysis cannot be applied to time >> series with missing values. >> To remove this error, I set: >> >> rain at _FillValue = 0.0 >> delete(rain at _FillValue) >> >> >> *Is there another way to avoid this? Like ignore the gridpoints with >> missing values and the input/output will still have the 3D dimension?* >> >> If I do something like this at the beginning, the input is no longer 3D. >> >> p1 = ndtooned( rain ) >> i = ind(.not.ismissing(p1)) ; all non-missing values >> if (.not.all(ismissing(i))) then >> rainNew = p1(i) ; rainNew is 1D >> copy_VarAtts (rain, rainNew) ; copy attributes >> else >> print("No missing values") >> end if >> >> --Lynz >> >> >> >> >> On Wed, Aug 9, 2023 at 5:13?PM Rashed Mahmood >> wrote: >> >>> Hi Lyndz, >>> There are several problems with your code. I do not have time to explain >>> these issues but you can compare the two codes to see the differences. The >>> below code should work, however, you need to think about what output you >>> are expecting and do testing of the results. I am not an expert on spectral >>> analysis so you will need to make sure if the results are as expected. >>> >>> >>> begin >>> ntim = 6954 >>> nlat = 220 >>> nlon = 220 >>> ;rain = random_normal(6.5,19.8,(/ntim,nlat,nlon/)) >>> nseg = 49 >>> nlen = ntim/nseg >>> minlat = -14.875 >>> maxlat = 39.875 >>> minlon = 90.125 >>> maxlon = 144.875 >>> spcavgFin = new((/nlen/2,nlat,nlon/),float) >>> ;onedtond(rain,(/nseg,nlat,nlon/)) >>> r1zsumFin = new((/nlat,nlon/),float) >>> printVarSummary(spcavgFin) >>> dm = 1 >>> sm = 1 >>> pct = 0.10 >>> ;r1zsum = 0.0 >>> >>> mlon=220 >>> nlat=220 >>> do nl=0,nlat-1 >>> do ml=0,mlon-1 >>> r1zsum =0. >>> spcavg =new(nlen/2,float) >>> spcavg =0. >>> do n=0,nseg-1 >>> ;print(n+"") >>> ;dof = >>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>> current segment spc >>> dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) ; >>> assuming rain has dims as: (time, lat, lon) >>> spcavg = spcavg + dof at spcx ; sum spc of each >>> segment >>> r1 = dof at xlag1 ; extract segment lag-1 >>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >>> end do >>> r1z = r1zsum/nseg ; average r1z >>> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >>> r1zsumFin(nl,ml) = r1 ; this is the mean r1 >>> spcavgFin(:,nl,ml) = spcavg/nseg ; average spectrum >>> delete([/r1z,r1/]) >>> end do ; ml >>> end do ; nl >>> end >>> >>> Good luck. >>> Rashed >>> >>> >>> On Wed, Aug 9, 2023 at 9:16?AM Lyndz via ncl-talk < >>> ncl-talk at mailman.ucar.edu> wrote: >>> >>>> Dear NCL-experts, >>>> >>>> Just a follow up on my post earlier. >>>> >>>> I tried the following: >>>> >>>> >>>> ;************************************************ >>>> ; calculate mean spectrum spectrum and lag1 auto cor >>>> ;************************************************ >>>> >>>> ntim = 6954 >>>> nlat = 220 >>>> nlon = 220 >>>> nseg = 49 >>>> nlen = ntim/nseg >>>> minlat = -14.875 >>>> maxlat = 39.875 >>>> minlon = 90.125 >>>> maxlon = 144.875 >>>> spcavg = onedtond(rain,(/nseg,nlat,nlon/)) >>>> printVarSummary(spcavg) >>>> spcavg = 0.0 >>>> r1zsum = 0.0 >>>> >>>> dm = 1 >>>> sm = 1 >>>> pct = 0.10 >>>> r1zsum = 0.0 >>>> >>>> mlon=220 >>>> nlat=220 >>>> >>>> do nl=0,nlat-1 >>>> do ml=0,mlon-1 >>>> do n=0,nseg-1 >>>> dof = >>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>> current segment spc >>>> spcavg = spcavg + dof at spcx ; sum spc of each >>>> segment >>>> r1 = dof at xlag1 ; extract segment >>>> lag-1 >>>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >>>> end do >>>> end do ; ml >>>> end do ; nl >>>> >>>> >>>> It gives the following error: >>>> >>>> ncl 64> do nl=0,nlat-1 >>>> ncl 65> do ml=0,mlon-1 >>>> ncl 66> do n=0,nseg-1 >>>> ncl 67> dof = >>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>> current segment spc >>>> ncl 68> spcavg = spcavg + dof at spcx ; sum spc of >>>> each segment >>>> ncl 69> r1 = dof at xlag1 ; extract >>>> segment lag-1 >>>> ncl 70> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the >>>> Fischer Z >>>> ncl 71> end do >>>> ncl 72> end do ; ml >>>> ncl 73> end do ; nl >>>> >>>> >>>> *fatal:Number of dimensions in parameter (0) of (specx_anal) is (3), >>>> (1) dimensions were expected fatal:["Execute.c":8635]:Execute: Error >>>> occurred at or near line 67* >>>> >>>> >>>> Any suggestion on how to do this correctly in NCL? >>>> >>>> -Lyndz >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> >>>> Dear NCL-experts, >>>> >>>> I would like to do a spectral analysis on a *ntim x nlat x lon* data >>>> as indicated in example 3 from this page: >>>> https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml >>>> >>>> *Specifically, I would like to get the mean spectra so that the final >>>> output will have meanspectra x lat x lon* >>>> >>>> >>>> *So far, I have the following:* >>>> >>>> ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open >>>> netcdf file >>>> rain = ufile->rAnom_sm(:,:,:) >>>> >>>> printVarSummary(rain) ;[time | 6954] x [latitude | 220] x >>>> [longitude | 220] >>>> >>>> d = 0 >>>> sm = 1 ; periodogram >>>> pct = 0.10 >>>> >>>> >>>> ;************************************************ >>>> ; calculate mean spectrum spectrum and lag1 auto cor >>>> ;************************************************ >>>> >>>> ntim = 6954 >>>> nlat = 220 >>>> nlon = 220 >>>> >>>> nseg = 49 >>>> nlen = ntim/nseg >>>> >>>> spcavg = new (ntim/141, typeof(rain)) >>>> printVarSummary(spcavg) >>>> spcavg = new ( ntim/2, typeof(rain)) >>>> spcavg = 0.0 >>>> r1zsum = 0.0 >>>> >>>> do n=0,nseg-1 >>>> dof = >>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>> current segment spc >>>> spcavg = spcavg + dof at spcx ; sum spc of each >>>> segment >>>> r1 = dof at xlag1 ; extract segment lag-1 >>>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z >>>> end do >>>> r1z = r1zsum/nseg ; average r1z >>>> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >>>> >>>> ; this is the mean r1 >>>> spcavg = spcavg/nseg ; average >>>> spectrum >>>> >>>> *Questions:* >>>> (1) How do I loop this across all the gridpoints? I am having a >>>> problem with the looping and saving the spectra in spcavg(ntim,nlat,nlon). >>>> Any suggestions on how to do this in NCL? The example in the page is >>>> incomplete. >>>> >>>> >>>> I'll appreciate any help on this. >>>> >>>> >>>> -Lyndz >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> ncl-talk mailing list >>>> ncl-talk at mailman.ucar.edu >>>> List instructions, subscriber options, unsubscribe: >>>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk >>>> >>> _______________________________________________ >> ncl-talk mailing list >> ncl-talk at mailman.ucar.edu >> List instructions, subscriber options, unsubscribe: >> https://mailman.ucar.edu/mailman/listinfo/ncl-talk >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: spectral_analysis.ncl Type: application/octet-stream Size: 2248 bytes Desc: not available URL: From dave.allured at noaa.gov Thu Aug 10 21:44:17 2023 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Thu, 10 Aug 2023 21:44:17 -0600 Subject: [ncl-talk] problem with specx_anal (ntim x nlat x nlon) In-Reply-To: References: Message-ID: Here is an untested modification of your second posted version. This should solve the missing value and dimension problems. This avoids using ndtooned, which I think is unnecessary and complicated here. Please add the necessary setup and reader code at the top. spcavg = new (ntim/2, typeof(rain)) spcavg = 0.0 r1zsum = 0.0 nvalid = 0 do nl=0,nlat-1 do ml=0,mlon-1 seg = rain(latitude|nl,longitude|ml,time|:) ; extract 1-D grid point if (.not. any (ismissing (seg))) then nvalid = nvalid + 1 dof = specx_anal (seg, d, sm, pct) ; current segment spc spcavg = spcavg + dof at spcx ; sum spc of each segment r1 = dof at xlag1 ; extract segment lag-1 r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z end if end do ; ml print ("nl, nvalid = " + nl + " " + nvalid) end do ; nl r1z = r1zsum/nvalid ; average r1z spcavg = spcavg/nvalid ; average spectrum On Thu, Aug 10, 2023 at 8:32?PM Lyndz via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dear Sir Dennis, NCL-experts. > > Thank you for this valuable information! > > Do you have any suggestions on how to solve this issue? > > *fatal:specx_anal: 'x' cannot contain any missing > valuesfatal:["Execute.c":8637]:Execute: Error occurred at or near line 69 > in file spectral_analysis.ncl* > > *from this line:* > dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) ; > assuming rain has dims as: (time, lat, lon) > > I checked the diagnostic functions from the MJO page( > https://www.ncl.ucar.edu/Document/Functions/Diagnostics/index.shtml). > The closest one that I was trying to do is using the mjo_spectra_season > > . > But this one is for area averaged spectra. I would like to do the spectral > analysis for all grid points with valid values. > > Thank you for all the help. > > Sincerely, > Lyndz > > > On Fri, Aug 11, 2023 at 9:24?AM Dennis Shea wrote: > >> [1] The spectral analysis function uses an FFT. Missing values >> [_FillValue] are not allowed. >> [2] You should *never* substitute a value [say, 0.0] for missing values. >> You will get numbers returned but they are *not* the correct numbers. Value >> substitution creates an erroneous spectrum. >> [3] My recollection of the way NCL executes the *specx_anal* >> * >> function *is >> [a] the *time series for* *each individual grid point *is examined >> prior to invoking the FFT >> [b] If the grid point time series contains one or more missing >> values, an error counter is incremented: ERR=ERR+1 >> [c] If no missing values are present, the spectral information for >> that grid point is computed. >> [d] *after* looping through all the grid points, if 'ERR' is non >> zero, the error message is issued to the user BUT the grid points with no >> _FillValue should have useable numbers. >> >> Good Luck >> >> >> On Thu, Aug 10, 2023 at 1:47?AM Lyndz via ncl-talk < >> ncl-talk at mailman.ucar.edu> wrote: >> >>> Dear Rashed, NCL-experts, >>> >>> Many thanks for this. >>> My goal is actually to plot the fractional variance as a map after >>> getting the mean spectra, >>> Something like this, which I can get from the average spectra: >>> >>> 5-to-10day variance: var_510 = SUM{*spcx*('f5->f10')*df} >>> >>> fractional_variance = var_510/total_variance >>> Attached is the modified script following your suggestion and I got this >>> error: >>> fatal:specx_anal: 'x' cannot contain any missing values >>> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 69 in >>> file spectral_analysis.ncl >>> >>> Im using the Aphrodite rainfall data set with missing values over the >>> ocean and some landpoints. spectral analysis cannot be applied to time >>> series with missing values. >>> To remove this error, I set: >>> >>> rain at _FillValue = 0.0 >>> delete(rain at _FillValue) >>> >>> *Is there another way to avoid this? Like ignore the gridpoints with >>> missing values and the input/output will still have the 3D dimension?* >>> >>> If I do something like this at the beginning, the input is no longer 3D. >>> >>> p1 = ndtooned( rain ) >>> i = ind(.not.ismissing(p1)) ; all non-missing values >>> if (.not.all(ismissing(i))) then >>> rainNew = p1(i) ; rainNew is 1D >>> copy_VarAtts (rain, rainNew) ; copy attributes >>> else >>> print("No missing values") >>> end if >>> >>> --Lynz >>> >>> >>> >>> On Wed, Aug 9, 2023 at 5:13?PM Rashed Mahmood >>> wrote: >>> >>>> Hi Lyndz, >>>> There are several problems with your code. I do not have time to >>>> explain these issues but you can compare the two codes to see the >>>> differences. The below code should work, however, you need to think about >>>> what output you are expecting and do testing of the results. I am not an >>>> expert on spectral analysis so you will need to make sure if the results >>>> are as expected. >>>> >>>> begin >>>> ntim = 6954 >>>> nlat = 220 >>>> nlon = 220 >>>> ;rain = random_normal(6.5,19.8,(/ntim,nlat,nlon/)) >>>> nseg = 49 >>>> nlen = ntim/nseg >>>> minlat = -14.875 >>>> maxlat = 39.875 >>>> minlon = 90.125 >>>> maxlon = 144.875 >>>> spcavgFin = new((/nlen/2,nlat,nlon/),float) >>>> ;onedtond(rain,(/nseg,nlat,nlon/)) >>>> r1zsumFin = new((/nlat,nlon/),float) >>>> printVarSummary(spcavgFin) >>>> dm = 1 >>>> sm = 1 >>>> pct = 0.10 >>>> ;r1zsum = 0.0 >>>> >>>> mlon=220 >>>> nlat=220 >>>> do nl=0,nlat-1 >>>> do ml=0,mlon-1 >>>> r1zsum =0. >>>> spcavg =new(nlen/2,float) >>>> spcavg =0. >>>> do n=0,nseg-1 >>>> ;print(n+"") >>>> ;dof = >>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>> current segment spc >>>> dof = specx_anal(rain(n*nlen:(n+1)*nlen-1,nl,ml),dm,sm,pct) >>>> ; assuming rain has dims as: (time, lat, lon) >>>> spcavg = spcavg + dof at spcx ; sum spc of each >>>> segment >>>> r1 = dof at xlag1 ; extract segment >>>> lag-1 >>>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >>>> end do >>>> r1z = r1zsum/nseg ; average r1z >>>> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >>>> r1zsumFin(nl,ml) = r1 ; this is the mean r1 >>>> spcavgFin(:,nl,ml) = spcavg/nseg ; average spectrum >>>> delete([/r1z,r1/]) >>>> end do ; ml >>>> end do ; nl >>>> end >>>> >>>> Good luck. >>>> Rashed >>>> >>>> >>>> On Wed, Aug 9, 2023 at 9:16?AM Lyndz via ncl-talk < >>>> ncl-talk at mailman.ucar.edu> wrote: >>>> >>>>> Dear NCL-experts, >>>>> >>>>> Just a follow up on my post earlier. >>>>> >>>>> I tried the following: >>>>> >>>>> ;************************************************ >>>>> ; calculate mean spectrum spectrum and lag1 auto cor >>>>> ;************************************************ >>>>> >>>>> ntim = 6954 >>>>> nlat = 220 >>>>> nlon = 220 >>>>> nseg = 49 >>>>> nlen = ntim/nseg >>>>> minlat = -14.875 >>>>> maxlat = 39.875 >>>>> minlon = 90.125 >>>>> maxlon = 144.875 >>>>> spcavg = onedtond(rain,(/nseg,nlat,nlon/)) >>>>> printVarSummary(spcavg) >>>>> spcavg = 0.0 >>>>> r1zsum = 0.0 >>>>> >>>>> dm = 1 >>>>> sm = 1 >>>>> pct = 0.10 >>>>> r1zsum = 0.0 >>>>> >>>>> mlon=220 >>>>> nlat=220 >>>>> >>>>> do nl=0,nlat-1 >>>>> do ml=0,mlon-1 >>>>> do n=0,nseg-1 >>>>> dof = >>>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>>> current segment spc >>>>> spcavg = spcavg + dof at spcx ; sum spc of each >>>>> segment >>>>> r1 = dof at xlag1 ; extract segment >>>>> lag-1 >>>>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the Fischer Z >>>>> end do >>>>> end do ; ml >>>>> end do ; nl >>>>> >>>>> It gives the following error: >>>>> >>>>> ncl 64> do nl=0,nlat-1 >>>>> ncl 65> do ml=0,mlon-1 >>>>> ncl 66> do n=0,nseg-1 >>>>> ncl 67> dof = >>>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>>> current segment spc >>>>> ncl 68> spcavg = spcavg + dof at spcx ; sum spc of >>>>> each segment >>>>> ncl 69> r1 = dof at xlag1 ; extract >>>>> segment lag-1 >>>>> ncl 70> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1))) ; sum the >>>>> Fischer Z >>>>> ncl 71> end do >>>>> ncl 72> end do ; ml >>>>> ncl 73> end do ; nl >>>>> >>>>> >>>>> *fatal:Number of dimensions in parameter (0) of (specx_anal) is (3), >>>>> (1) dimensions were expected fatal:["Execute.c":8635]:Execute: Error >>>>> occurred at or near line 67* >>>>> >>>>> Any suggestion on how to do this correctly in NCL? >>>>> >>>>> -Lyndz >>>>> >>>>> >>>>> Dear NCL-experts, >>>>> >>>>> I would like to do a spectral analysis on a *ntim x nlat x lon* data >>>>> as indicated in example 3 from this page: >>>>> https://www.ncl.ucar.edu/Document/Functions/Built-in/specx_anal.shtml >>>>> >>>>> *Specifically, I would like to get the mean spectra so that the final >>>>> output will have meanspectra x lat x lon* >>>>> >>>>> *So far, I have the following:* >>>>> >>>>> ufile = addfile("anom_rain_sm_1951-2007_jjas.nc","r") ; open >>>>> netcdf file >>>>> rain = ufile->rAnom_sm(:,:,:) >>>>> >>>>> printVarSummary(rain) ;[time | 6954] x [latitude | 220] x >>>>> [longitude | 220] >>>>> >>>>> d = 0 >>>>> sm = 1 ; periodogram >>>>> pct = 0.10 >>>>> >>>>> ;************************************************ >>>>> ; calculate mean spectrum spectrum and lag1 auto cor >>>>> ;************************************************ >>>>> >>>>> ntim = 6954 >>>>> nlat = 220 >>>>> nlon = 220 >>>>> >>>>> nseg = 49 >>>>> nlen = ntim/nseg >>>>> >>>>> spcavg = new (ntim/141, typeof(rain)) >>>>> printVarSummary(spcavg) >>>>> spcavg = new ( ntim/2, typeof(rain)) >>>>> spcavg = 0.0 >>>>> r1zsum = 0.0 >>>>> >>>>> do n=0,nseg-1 >>>>> dof = >>>>> specx_anal(rain(latitude|nl:nl,longitude|ml:ml,time|:),d,sm,pct) ; >>>>> current segment spc >>>>> spcavg = spcavg + dof at spcx ; sum spc of each >>>>> segment >>>>> r1 = dof at xlag1 ; extract segment >>>>> lag-1 >>>>> r1zsum = r1zsum + 0.5*(log((1+r1)/(1-r1)) ; sum the Fischer Z >>>>> end do >>>>> r1z = r1zsum/nseg ; average r1z >>>>> r1 = (exp(2*r1z)-1)/(exp(2*r1z)+1) ; transform back >>>>> >>>>> ; this is the mean r1 >>>>> spcavg = spcavg/nseg ; average >>>>> spectrum >>>>> >>>>> *Questions:* >>>>> (1) How do I loop this across all the gridpoints? I am having a >>>>> problem with the looping and saving the spectra in spcavg(ntim,nlat,nlon). >>>>> Any suggestions on how to do this in NCL? The example in the page is >>>>> incomplete. >>>>> >>>>> I'll appreciate any help on this. >>>>> >>>>> -Lyndz >>>>> >>>> -------------- next part -------------- An HTML attachment was scrubbed... URL: From dmjalal90 at gmail.com Wed Aug 16 03:17:25 2023 From: dmjalal90 at gmail.com (Md. Jalal Uddin) Date: Wed, 16 Aug 2023 18:17:25 +0900 Subject: [ncl-talk] Regridding problem for a CSV file data Message-ID: Dear all, I have a pressure data (lat, lon, and pressure), and reshaped it ([81] x [85] ) using the onedtond function in ncl. After that, I tried to plot a similar figure like https://www.ncl.ucar.edu/Applications/Images/regrid_15_2_lg.png. But the problem is to conform the pressure data with latlon. The full code and data are attached herewith. Any suggestions would be appreciated. -- *Regards,* Dr. Jalal *Postdoctoral Researcher,* Typhoon Research Center, Jeju National University, South Korea *PhD* in Atmospheric Physics and Atmospheric Environment, NUIST, China *M.Sc.* in Applied Meteorology, NUIST, China *B.Sc.* in Disaster Management, PSTU, Bangladesh *Founder and Director* of Research Society -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: testpre.csv Type: text/csv Size: 116720 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Nanmadol_300km.ncl Type: application/octet-stream Size: 3144 bytes Desc: not available URL: From andrew.kren at noaa.gov Sun Aug 20 15:29:28 2023 From: andrew.kren at noaa.gov (Andrew Kren - NOAA Federal) Date: Sun, 20 Aug 2023 17:29:28 -0400 Subject: [ncl-talk] Issue with shapefile highways showing up on map Message-ID: Hi there, For some reason I am running into issues with my highways not showing up when trying to plot them. As a context, we moved the scripts to a new computer. The old computer has the same code and it worked fine. Now when we installed NCL on the new machine, the script runs but does not plot the polylines. I have been using gsn_add_shapefile_polylines_subset to plot a select number of highways. I verified that the function is reading correctly, and there are no error messages showing up when running NCL. I am at a loss for what could be going on. Here is a snippet of my code where I plot the highways: if (plot_highways.eq."Yes".or.plot_highways.eq."yes") then ; add highways ;---Section to add polylines to map. plres_high = True ; resource list for polylines colors_hwy = highway_colors ;plres at gsLineColor = "(/0.66, 0.66, 0.66/)" plres at gsEdgesOn = True plres at gsFillColor = "transparent" plres at gsFillOpacityF = 0.0 plres_high at gsLineThicknessF = 2.0 highways = highway_names poly_high = gsn_add_shapefile_polylines_subset(wks,plot,SHAPE_DIR+shapefile_file,shapefile_descriptor,highways,colors_hwy,plres_high) end if Could this be a path issue with where NCL was installed? I can't imagine it would be since it runs fine. Much appreciated for any help! -- Andrew Kren Meteorologist NOAA's National Weather Service Raleigh Forecast Office 1005 Capability Drive, Suite 300 Raleigh, North Carolina 27606 voice: 919-326-1035 mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.allured at noaa.gov Sun Aug 20 16:18:52 2023 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Sun, 20 Aug 2023 16:18:52 -0600 Subject: [ncl-talk] Issue with shapefile highways showing up on map In-Reply-To: References: Message-ID: This might be a known issue, swapped X and Y coordinates in the shapefile reader. Verify by changing your plot region, and see if the features show up in a different place on the globe. The alternate location is predictable. https://github.com/NCAR/ncl/issues/176 This was never fully investigated. This may be due to a version update in one of the support libraries, such as GDAL, on your new machine. There is a suggested workaround in that issue. On Sun, Aug 20, 2023 at 3:30?PM Andrew Kren - NOAA Federal via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Hi there, > > For some reason I am running into issues with my highways not showing up > when trying to plot them. As a context, we moved the scripts to a new > computer. The old computer has the same code and it worked fine. Now when > we installed NCL on the new machine, the script runs but does not plot the > polylines. > > I have been using gsn_add_shapefile_polylines_subset to plot a select > number of highways. I verified that the function is reading correctly, and > there are no error messages showing up when running NCL. I am at a loss for > what could be going on. Here is a snippet of my code where I plot the > highways: > > if (plot_highways.eq."Yes".or.plot_highways.eq."yes") then > ; add highways > ;---Section to add polylines to map. > plres_high = True ; resource list for polylines > colors_hwy = highway_colors > ;plres at gsLineColor = "(/0.66, 0.66, 0.66/)" > plres at gsEdgesOn = True > plres at gsFillColor = "transparent" > plres at gsFillOpacityF = 0.0 > plres_high at gsLineThicknessF = 2.0 > highways = highway_names > poly_high = > gsn_add_shapefile_polylines_subset(wks,plot,SHAPE_DIR+shapefile_file,shapefile_descriptor,highways,colors_hwy,plres_high) > end if > > Could this be a path issue with where NCL was installed? I can't imagine > it would be since it runs fine. Much appreciated for any help! > -- > > Andrew Kren > Meteorologist > NOAA's National Weather Service > Raleigh Forecast Office > 1005 Capability Drive, Suite 300 > Raleigh, North Carolina 27606 > voice: 919-326-1035 > mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.allured at noaa.gov Sun Aug 20 17:58:47 2023 From: dave.allured at noaa.gov (Dave Allured - NOAA Affiliate) Date: Sun, 20 Aug 2023 17:58:47 -0600 Subject: [ncl-talk] Issue with shapefile highways showing up on map In-Reply-To: References: Message-ID: Andrew said that didn't work. Does anyone else have an idea about this failure to plot polylines? On Sun, Aug 20, 2023 at 4:18?PM Dave Allured - NOAA Affiliate < dave.allured at noaa.gov> wrote: > This might be a known issue, swapped X and Y coordinates in the shapefile > reader. Verify by changing your plot region, and see if the features show > up in a different place on the globe. The alternate location is > predictable. > https://github.com/NCAR/ncl/issues/176 > > This was never fully investigated. This may be due to a version update > in one of the support libraries, such as GDAL, on your new machine. There > is a suggested workaround in that issue. > > > On Sun, Aug 20, 2023 at 3:30?PM Andrew Kren - NOAA Federal via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Hi there, >> >> For some reason I am running into issues with my highways not showing up >> when trying to plot them. As a context, we moved the scripts to a new >> computer. The old computer has the same code and it worked fine. Now when >> we installed NCL on the new machine, the script runs but does not plot the >> polylines. >> >> I have been using gsn_add_shapefile_polylines_subset to plot a select >> number of highways. I verified that the function is reading correctly, and >> there are no error messages showing up when running NCL. I am at a loss for >> what could be going on. Here is a snippet of my code where I plot the >> highways: >> >> if (plot_highways.eq."Yes".or.plot_highways.eq."yes") then >> ; add highways >> ;---Section to add polylines to map. >> plres_high = True ; resource list for >> polylines >> colors_hwy = highway_colors >> ;plres at gsLineColor = "(/0.66, 0.66, 0.66/)" >> plres at gsEdgesOn = True >> plres at gsFillColor = "transparent" >> plres at gsFillOpacityF = 0.0 >> plres_high at gsLineThicknessF = 2.0 >> highways = highway_names >> poly_high = >> gsn_add_shapefile_polylines_subset(wks,plot,SHAPE_DIR+shapefile_file,shapefile_descriptor,highways,colors_hwy,plres_high) >> end if >> >> Could this be a path issue with where NCL was installed? I can't imagine >> it would be since it runs fine. Much appreciated for any help! >> -- >> >> Andrew Kren >> Meteorologist >> NOAA's National Weather Service >> Raleigh Forecast Office >> 1005 Capability Drive, Suite 300 >> Raleigh, North Carolina 27606 >> voice: 919-326-1035 >> mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From tabishumaransari at gmail.com Sun Aug 20 18:33:06 2023 From: tabishumaransari at gmail.com (Tabish Ansari) Date: Mon, 21 Aug 2023 02:33:06 +0200 Subject: [ncl-talk] Problem using contributed function "time_axes_labels" Message-ID: Hi I'm running an NCL script which utilizes the time_axes_labels function on two different machines. Since it is a contributed function, it needs to be loaded manually in the preamble. The script runs smoothly on one of the machines but fails on the other. I use these two lines in the beginning of my script: load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/contrib/cd_string.ncl" and the code snippet where I use the function is here: ;-------------------------------------------------- ; The time_axis_label function adds additional ; resources to "res" to produce nicely-formatted ; time labels on X axis. This function only works ; if you have a time "units" recognized by the ; cd_calendar function. ;-------------------------------------------------- restick = True restick at ttmFormat = "%Y" restick at ttmMajorStride= 12 restick at ttmMinorStride= 1 timearr = ispan (1,228,1) timearr at units = "months since 2000-01-01 00:00:00" time_axis_labels(timearr,res,restick) ; this is line no. 154 res at trXMaxF=max(timearr) I get the following error on one of the machines: fatal:["NclAtt.c":262]:Attribute assignment type mismatch. fatal:["Execute.c":8637]:Execute: Error occurred at or near line 214 in file $NCARG_ROOT/lib/ncarg/nclscripts/contrib/time_axis_labels.ncl fatal:["Execute.c":8637]:Execute: Error occurred at or near line 154 in file noxtagging-stackedcontributions.ncl Please let me know if you can spot something obviously wrong here. I'm running NCL 6.6.2 on both machines. Thanks. kind regards, Tabish -------------------------------------------------------------------------------------- Dr Tabish Ansari Research Associate Air Quality Modelling Group Research Institute for Sustainability (RIFS) - Helmholtz Centre Potsdam Potsdam, Germany -------------- next part -------------- An HTML attachment was scrubbed... URL: From brownrig at ucar.edu Sun Aug 20 21:36:25 2023 From: brownrig at ucar.edu (Rick Brownrigg) Date: Sun, 20 Aug 2023 21:36:25 -0600 Subject: [ncl-talk] Issue with shapefile highways showing up on map In-Reply-To: References: Message-ID: Andrew, would you mind sending me that shapefile? Rick On Sun, Aug 20, 2023 at 5:59?PM Dave Allured - NOAA Affiliate via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Andrew said that didn't work. Does anyone else have an idea about this > failure to plot polylines? > > > On Sun, Aug 20, 2023 at 4:18?PM Dave Allured - NOAA Affiliate < > dave.allured at noaa.gov> wrote: > >> This might be a known issue, swapped X and Y coordinates in the shapefile >> reader. Verify by changing your plot region, and see if the features show >> up in a different place on the globe. The alternate location is >> predictable. >> https://github.com/NCAR/ncl/issues/176 >> >> This was never fully investigated. This may be due to a version update >> in one of the support libraries, such as GDAL, on your new machine. There >> is a suggested workaround in that issue. >> >> >> On Sun, Aug 20, 2023 at 3:30?PM Andrew Kren - NOAA Federal via ncl-talk < >> ncl-talk at mailman.ucar.edu> wrote: >> >>> Hi there, >>> >>> For some reason I am running into issues with my highways not showing up >>> when trying to plot them. As a context, we moved the scripts to a new >>> computer. The old computer has the same code and it worked fine. Now when >>> we installed NCL on the new machine, the script runs but does not plot the >>> polylines. >>> >>> I have been using gsn_add_shapefile_polylines_subset to plot a select >>> number of highways. I verified that the function is reading correctly, and >>> there are no error messages showing up when running NCL. I am at a loss for >>> what could be going on. Here is a snippet of my code where I plot the >>> highways: >>> >>> if (plot_highways.eq."Yes".or.plot_highways.eq."yes") then >>> ; add highways >>> ;---Section to add polylines to map. >>> plres_high = True ; resource list for >>> polylines >>> colors_hwy = highway_colors >>> ;plres at gsLineColor = "(/0.66, 0.66, 0.66/)" >>> plres at gsEdgesOn = True >>> plres at gsFillColor = "transparent" >>> plres at gsFillOpacityF = 0.0 >>> plres_high at gsLineThicknessF = 2.0 >>> highways = highway_names >>> poly_high = >>> gsn_add_shapefile_polylines_subset(wks,plot,SHAPE_DIR+shapefile_file,shapefile_descriptor,highways,colors_hwy,plres_high) >>> end if >>> >>> Could this be a path issue with where NCL was installed? I can't imagine >>> it would be since it runs fine. Much appreciated for any help! >>> -- >>> >>> Andrew Kren >>> Meteorologist >>> NOAA's National Weather Service >>> Raleigh Forecast Office >>> 1005 Capability Drive, Suite 300 >>> Raleigh, North Carolina 27606 >>> voice: 919-326-1035 >>> mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah >>> >>> _______________________________________________ > ncl-talk mailing list > ncl-talk at mailman.ucar.edu > List instructions, subscriber options, unsubscribe: > https://mailman.ucar.edu/mailman/listinfo/ncl-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From G.Monte at isac.cnr.it Tue Aug 29 03:29:29 2023 From: G.Monte at isac.cnr.it (G.Monte at isac.cnr.it) Date: Tue, 29 Aug 2023 11:29:29 +0200 Subject: [ncl-talk] Problems with ESMF regridding Message-ID: Dears all, I have a problem with the regridding process; when I run the code whit the ESMF_regrid function, I get the following error in the screenshot: Regrid Method: bilinear Pole option: ALL Ignore unmapped destination points Ignore degenerate cells in the input grids Line Type: cartesian Norm Type: dstarea Extrap. Method: none ERROR: Problem on processor 0 . Please see the PET*.RegridWeightGen.Log files for a traceback. -------------------------------------------------- ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was not successful. ESMF_RegridWeightGenFile Library needed by ESMF not present - Internal subroutine call returned Error (in the log file) I also looked for this library and I found it, at least I suppose so. How can I solve this problem? Thanks in advance, Giulio Monte From barry.h.lynn at gmail.com Tue Aug 29 05:11:27 2023 From: barry.h.lynn at gmail.com (Barry Lynn) Date: Tue, 29 Aug 2023 14:11:27 +0300 Subject: [ncl-talk] Problems with ESMF regridding In-Reply-To: References: Message-ID: Hi: Are you regridding to a global grid? On Tue, Aug 29, 2023 at 12:29?PM G.Monte--- via ncl-talk < ncl-talk at mailman.ucar.edu> wrote: > Dears all, > > I have a problem with the regridding process; when I run the code whit the > ESMF_regrid function, I get the following error in the screenshot: > > Regrid Method: bilinear > Pole option: ALL > Ignore unmapped destination points > Ignore degenerate cells in the input grids > Line Type: cartesian > Norm Type: dstarea > Extrap. Method: none > > ERROR: Problem on processor 0 . Please see the > PET*.RegridWeightGen.Log files for a traceback. > -------------------------------------------------- > ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was not successful. > > ESMF_RegridWeightGenFile Library needed by ESMF not present - Internal > subroutine call returned Error (in the log file) > > I also looked for this library and I found it, at least I suppose so. How > can I solve this problem? > > Thanks in advance, > Giulio Monte > > _______________________________________________ > ncl-talk mailing list > ncl-talk at mailman.ucar.edu > List instructions, subscriber options, unsubscribe: > https://mailman.ucar.edu/mailman/listinfo/ncl-talk > -- Barry H. Lynn, Ph.D Senior Scientist, Lecturer, The Institute of Earth Sciences, The Hebrew University of Jerusalem, Givat Ram, Jerusalem 91904, Israel Tel: 972 547 231 170 Fax: (972)-25662581 Weather It Is, LTD Weather and Climate Focus https://weather-it-is.com Jerusalem, Israel Local: 02 930 9525 Cell: 054 7 231 170 Int-IS: x972 2 930 9525 -------------- next part -------------- An HTML attachment was scrubbed... URL: From barry.h.lynn at gmail.com Tue Aug 29 06:33:46 2023 From: barry.h.lynn at gmail.com (Barry Lynn) Date: Tue, 29 Aug 2023 15:33:46 +0300 Subject: [ncl-talk] Problems with ESMF regridding In-Reply-To: References: Message-ID: Hi: Perhaps this will help? precip_o = a_r->A_PCP_GDS5_SFC_acc1h dims_p = dimsizes(precip_o) print(dims_p) latitude := a_r->g5_lat_0 longitude := a_r->g5_lon_1 system("rm -f destination_grid_bulk_precip_file.nc ") system("rm -f source_grid_bulk_precip_file.nc") ; If you are regridding to an unstructured grid, set: ;https://www.ncl.ucar.edu/Applications/Scripts/ESMF_regrid_21.ncl Opt = True ; Opt at DstGridType = "unstructured" ; Opt at DstGridType = "curvilinear" ; Opt at InterpMethod = "bilinear" ;;---Change (maybe) ; Opt at InterpMethod = "conserve" ;;---Change (maybe) Opt at InterpMethod = "patch" ;;---Change (maybe) Opt at WgtFileName = "wrfout_temp_curv.nc" Opt at SrcGridLat := latitude Opt at SrcGridLon := longitude Opt at SrcRegional = True ;;--Change (maybe) ;SrcFileName is just the name you want to give the intermediate NetCDF file that gets created in order ;to describe your source grid to the ESMF_RegridWeightGen program. If you don't set this, the ;intermediate file will be called "source_grid_bulk_precip_file.nc". ;I suggest not setting this at all, or, if you do set it, call it something like "WRF_SCRIP_file.nc". ; Opt at SrcInputFileName = src_file ; optional, but good idea ; Opt at SrcInputFileName = a ; optional, but good idea Opt at DstGridLat = xlat2d(:,:) ; destination grid Opt at DstGridLon = xlon2d(:,:) Opt at DstRegional = True ;;--Change (maybe) Opt at ForceOverwrite = True Opt at PrintTimings = False Opt at Debug = True grid = ESMF_regrid(precip_o,Opt) ; Do the regridding printMinMax(grid,False) printVarSummary(grid) On Tue, Aug 29, 2023 at 2:11?PM Barry Lynn wrote: > Hi: > > Are you regridding to a global grid? > > On Tue, Aug 29, 2023 at 12:29?PM G.Monte--- via ncl-talk < > ncl-talk at mailman.ucar.edu> wrote: > >> Dears all, >> >> I have a problem with the regridding process; when I run the code whit the >> ESMF_regrid function, I get the following error in the screenshot: >> >> Regrid Method: bilinear >> Pole option: ALL >> Ignore unmapped destination points >> Ignore degenerate cells in the input grids >> Line Type: cartesian >> Norm Type: dstarea >> Extrap. Method: none >> >> ERROR: Problem on processor 0 . Please see the >> PET*.RegridWeightGen.Log files for a traceback. >> -------------------------------------------------- >> ESMF_regrid_gen_weights: 'ESMF_RegridWeightGen' was not successful. >> >> ESMF_RegridWeightGenFile Library needed by ESMF not present - Internal >> subroutine call returned Error (in the log file) >> >> I also looked for this library and I found it, at least I suppose so. How >> can I solve this problem? >> >> Thanks in advance, >> Giulio Monte >> >> _______________________________________________ >> ncl-talk mailing list >> ncl-talk at mailman.ucar.edu >> List instructions, subscriber options, unsubscribe: >> https://mailman.ucar.edu/mailman/listinfo/ncl-talk >> > > > -- > > Barry H. Lynn, Ph.D > Senior Scientist, Lecturer, > The Institute of Earth Sciences, > The Hebrew University of Jerusalem, > Givat Ram, Jerusalem 91904, Israel > Tel: 972 547 231 170 > Fax: (972)-25662581 > > Weather It Is, LTD > Weather and Climate Focus > https://weather-it-is.com > Jerusalem, Israel > Local: 02 930 9525 > Cell: 054 7 231 170 > Int-IS: x972 2 930 9525 > > -- Barry H. Lynn, Ph.D Senior Scientist, Lecturer, The Institute of Earth Sciences, The Hebrew University of Jerusalem, Givat Ram, Jerusalem 91904, Israel Tel: 972 547 231 170 Fax: (972)-25662581 Weather It Is, LTD Weather and Climate Focus https://weather-it-is.com Jerusalem, Israel Local: 02 930 9525 Cell: 054 7 231 170 Int-IS: x972 2 930 9525 -------------- next part -------------- An HTML attachment was scrubbed... URL: