From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>

Date: Wed, 03 May 2006 15:51:55 -0600

Date: Wed, 03 May 2006 15:51:55 -0600

Hi Alex,

My apologies, I didn't look closely enough at the local_min

documentation before I wrote that print statement. local_min returns the

index value of the latitudes and longitudes, not the latitudes and

longitudes themselves. So:

t = hgtnew&time

lat = hgtnew&lat

lon = hgtnew&lon

do i = 0,tend

.....

print("For t = "+i+", local_min exists at "+lat(nmin_at_yi)+"N, \

"+lon(nmin_at_xi)+"E, with a value of "+nmin_at_minval)

end do

As far as writing out the local_mins to a text file, that can get a bit

tricky. Each time through local_min can return a different number of

local minima. This is a problem, since in order to write all the data at

once (using write_matrix) we will have to store the local_min data at

every timestep in one data array.

Thus, you will have to ID the max number of local minima returned from

local_min, and set up an array based on that number * the total number

of timesteps. So (untested):

t = x&time

nmax = 0

do h = 0,dimsizes(t)-1

nmin = local_min(hgtnew(h,{60:90},:), True, 0.0)

nmax = max((/nmin,nmax/))

end do

print("Maximum number of minima = "+nmax)

nmax = nmax*dimsizes(t) ; set up array at max possible size

ncol = 4

data = new ( (/nmax,ncol/) , typeof(x) )

cntr = 0

do i = 0,tend

nmin = local_min(hgtnew(i,{60:90},:), True, 0.0)

data(cntr:cntr+nmin-1,0) = t(i)

data(cntr:cntr+nmin-1,1) = nmin_at_minval

data(cntr:cntr+nmin-1,2) = nmin_at_xi

data(cntr:cntr+nmin-1,3) = nmin_at_yi

cntr = cntr+nmin

end do

opt = True

opt_at_fout = "alexg.txt"

write_matrix( data(:cntr-1,:), "f10.1,3f10.2", opt)

Adam

Alex Gardner wrote:

*> Thanks Adam,
*

*>
*

*> I have 2 more questions:
*

*>
*

*> When I constrain my 2-D field to between 60 and 90 deg N ("(i,{60:90},:)" I
*

*> get output for between 1-5 deg N. Any clue why this might be? I'm using NCEP
*

*> netCDFs
*

*>
*

*> Instead of printing the output to the screen, is there a way to have each
*

*> loop's output added to a text file?
*

*>
*

*> Cheers,
*

*> Alex
*

*>
*

*> My Scrip now looks like this:
*

*>
*

*> begin
*

*> ;
*

*> tend = 24
*

*> ;
*

*> a = addfile("$NCARG_ROOT/netcdf/hgt.2002.nc","r")
*

*> hgt=a->hgt(:,5,:,:)
*

*>
*

*> hgtnew = (hgt*hgt_at_scale_factor) + hgt_at_add_offset
*

*> copy_VarMeta(hgt,hgtnew)
*

*>
*

*> do i = 0,tend,1
*

*>
*

*> x = hgtnew(i,{60:90},:)
*

*> nmin = local_min(x, True, 0.0)
*

*>
*

*> print("For t = "+i+", local_min exists at "+nmin_at_yi+"N, \ "+nmin_at_xi+"E, with
*

*> a value of "+nmin_at_minval)
*

*>
*

*>
*

*> -----Original Message-----
*

*> From: Adam Phillips [mailto:asphilli_at_cgd.ucar.edu]
*

*> Sent: Wednesday, May 03, 2006 2:03 PM
*

*> To: Alex Gardner
*

*> Cc: ncl-talk_at_ucar.edu
*

*> Subject: Re: High Pressure Ridge Identification Algorithm?
*

*>
*

*> Hi Alex,
*

*>
*

*> local_min / local_max only accept 2 dimensional data:
*

*>
*

*> http://www.ncl.ucar.edu/Document/Functions/Built-in/local_min.shtml
*

*>
*

*> As you have 3D data, you need to put in a do loop for the time dimension:
*

*>
*

*> t = x&time
*

*> do gg = 0,dimsizes(t)-1
*

*> nmin = local_min(x(gg,:,:), True, delta)
*

*> print("For t = "+t(gg)+", local_min exists at "+nmin_at_yi+"N, \
*

*> "+nmin_at_xi+"E, with a value of "+nmin_at_minval)
*

*> end do
*

*>
*

*> Adam
*

*>
*

*> Alex Gardner wrote:
*

*>
*

*>>Thanks again Dennis, you've been a great help.
*

*>>
*

*>>I've tired running the scrip but I keep getting the error message:
*

*>>
*

*>>"Fatal: Number of dimensions in parameter (0) of (local_min) is (3), (2)
*

*>>dimensions were expected"
*

*>>
*

*>>The scrip I have so for is:
*

*>>
*

*>>a = addfile("$NCARG_ROOT/netcdf/hgt.2002.nc","r")
*

*>>x=a->hgt(:,5,{60:},:)
*

*>>
*

*>>t = x&time
*

*>>ntim = dimsizes(t)
*

*>>
*

*>> delta = 0. ; user specified
*

*>> nmin = local_min(x, True, delta)
*

*>>
*

*>> ncol = 4
*

*>> data = new ( (/ntim,ncol/) , typeof(x) )
*

*>> data(:,0) = t
*

*>> data(:,1) = nmin_at_minval
*

*>> data(:,2) = nmin_at_xi
*

*>> data(:,3) = nmin_at_yi
*

*>>
*

*>> opt = True
*

*>> opt_at_fout = "alexg.txt"
*

*>> write_matrix( data, "f10.1,3f10.2", opt)
*

*>>
*

*>>end
*

*>>
*

*>>The problem has to do with the time component of the field "hgt".
*

*>
*

*> Local_min
*

*>
*

*>>doesn't seem to work when all time steps are extracted.
*

*>>
*

*>>Do you know how can I solve this issue?
*

*>>
*

*>>Alex
*

*>>
*

*>>-----Original Message-----
*

*>>From: Dennis Shea [mailto:shea_at_cgd.ucar.edu]
*

*>>Sent: Tuesday, May 02, 2006 2:46 PM
*

*>>To: ncl-talk_at_ucar.edu; alexg_at_ualberta.ca
*

*>>Subject: RE: [ncl-talk] High Pressure Ridge Identification Algorithm?
*

*>>
*

*>>
*

*>>
*

*>>>Thank you very much for the help Dennis,
*

*>>>
*

*>>>The min and max functions will do what I want. What I eventually want to
*

*>
*

*> do
*

*>
*

*>>>is output the min value, lat and long for each month of a 2 year monthly
*

*>>>mean netCDF file for the region North of 60 deg North. Ideally I would
*

*>
*

*> like
*

*>
*

*>>>to run a script that could output a single txt file with the year, month,
*

*>>>value, lat, and long for each month of the 24 months the netCDF. Does
*

*>>
*

*>>anyone
*

*>>
*

*>>
*

*>>>have a script where they have used the locmin or locmax functions with a
*

*>>>netcdf file and output the results as a txt file?
*

*>>>
*

*>>>Any help would be greatly appreciated.
*

*>>
*

*>>
*

*>>quick/dirty/ and untested
*

*>>
*

*>> f = addfile (... , "r")
*

*>> ; read data nort of 60
*

*>> x = f->X(:,{60:},:) ; x(time,lat,lon) => (24,:,:)
*

*>> t = x&time
*

*>> ntim = dimsizes(t)
*

*>>
*

*>> delta = ... ; user specified
*

*>> nmin = local_min(x, True, delta)
*

*>> ; ????
*

*>> ncol = 4
*

*>> data = new ( (/ntim,ncol/) , typeof(x) )
*

*>> data(:,0) = t
*

*>> data(:,1) = nmin_at_minval
*

*>> data(:,2) = nmin_at_xi
*

*>> data(:,3) = nmin_at_yi
*

*>>
*

*>> opt = True
*

*>> opt_at_fout = "alexg.txt"
*

*>> write_matrix( data, "f10.1,3f10.2", opt)
*

*>>
*

*>>
*

*>>
*

*>>>
*

*>>>
*

*>>>-----Original Message-----
*

*>>>From: Dennis Shea [mailto:shea_at_cgd.ucar.edu]
*

*>>>Sent: Monday, May 01, 2006 3:35 PM
*

*>>>To: ncl-talk_at_ucar.edu; alexg_at_ualberta.ca
*

*>>>Subject: Re: High Pressure Ridge Identification Algorithm?
*

*>>>
*

*>>>
*

*>>>
*

*>>>>I know it's a long shot, but does anyone know if there is an atmospheric
*

*>>>>ridge detection (from netCDF files) function that has been developed for
*

*>>>>NCL? I'm looking to develop statistics on ridging event over a particular
*

*>>>>region and was hoping that maybe someone has done similar work.
*

*>>>>_______________________________________________
*

*>>>
*

*>>>I know of no ready made software.
*

*>>>
*

*>>>---
*

*>>>Having said that ...
*

*>>>
*

*>>>What do you mean by "atmospheric ridge detection"?
*

*>>>
*

*>>>Are you talking about atmospheric "blocks" ?
*

*>>>ie: blocking highs , blocking patterns
*

*>>>
*

*>>>---
*

*>>>There are functions that can automate detection
*

*>>>of local min and max of 2D fileds
*

*>>>
*

*>>>
*

*>>>http://www.ncl.ucar.edu/Document/Functions/Built-in/local_max.shtml
*

*>>>
*

*>>>An example is at:
*

*>>>http://www.ncl.ucar.edu/Applications/minmax.shtml
*

*>>>
*

*>>>good luck
*

*>>>
*

*>>
*

*>>
*

*>>
*

*>>_______________________________________________
*

*>>ncl-talk mailing list
*

*>>ncl-talk_at_ucar.edu
*

*>>http://mailman.ucar.edu/mailman/listinfo/ncl-talk
*

*>
*

*>
*

-- -------------------------------------------------------------- Adam Phillips asphilli_at_ucar.edu National Center for Atmospheric Research tel: (303) 497-1726 ESSL/CGD/CAS fax: (303) 497-1333 P.O. Box 3000 Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli _______________________________________________ ncl-talk mailing list ncl-talk_at_ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed May 03 2006 - 15:51:55 MDT

*
This archive was generated by hypermail 2.2.0
: Wed May 03 2006 - 21:11:42 MDT
*