Return to Ferret FAQ


Finding the location of last isotherm


Question:

I would like to find the location of the northernmost isotherm, but @LOC finds the first one, starting in the south.

Example:


Say I want to find the location of 2C between the equator and 80S. To demonstrate clearly, Assume that the contours look like this

-------------------------- 2C ----------------- 60S (I want to get this location)
-------------------------- 3C ----------------- 65S
-------------------------- 4C ----------------- 70S 
-------------------------- 3C ----------------- 75S
-------------------------- 2C ----------------- 80S (not this)


yes? LET iso2 = sst[y=80S:60S@LOC:2.0]
iso2 would return the location of the 2C from south to north, that I get 80S. Is there anyway that I can locate the first 2C isotherm from north to south instead of south to north?

Explanation:

The @LOC transformation finds the first instance of the desired value, along the given axis starting at its beginning (90S for this latitude axis). We want a later crossing of the value. One might think of reordering the data using SAMPLEJ, or perhaps read in the data if it is a NetCDF dataset using the USE/ORDER qualifier. But here is a more direct and general approach.

Solution:

We can use the @EVNT transformation to define a mask, so as to work with the data only at the last crossing of the desired value (or the second-to-last, etc).

We will construct an example using the SALT variable from the dataset levitus_climatology

yes? USE levitus_climatology
yes? SET REG/K=1
yes? SHADE/LEV=(30,40,1) salt; go fland 20

[Output Graphic]

! Get all the places where SALT crosses the value 35. ! At various longitudes, there are places where this does ! not happen at all; in other locations it crosses 35 ! once, twice, even 6 times. @EVNT is incremented each ! time the event occurs. yes? LET cross_35 = salt[Y=@EVNT:35] yes? SHADE cross_35; go fland 20

[Output Graphic]

! Where is the last crossing, counting south to north? yes? LET last_cross = cross_35[Y=@MAX] yes? PLOT last_cross

[Output Graphic]

! Make a mask for SALT, keep only the data after the last crossing yes? LET mask_last = IF cross_35 EQ last_cross THEN 1 yes? LET salt_mask = salt* mask_last yes? SHADE salt_mask; go fland 20

[Output Graphic]

! What we really want is the location of the southernmost shaded ! latitude at each longitude on the above plot. We might think ! to use @LOC:35 on the variable salt_mask, but that points to ! the next crossing of the value 35, and we are already at the ! last crossing. Let's make a new mask, the next-to-last crossing. yes? LET next_last = MAX(last_cross-1, 0) yes? LET mask_next_last = IF cross_35 GE next_last THEN 1 ! This masked variable contains all data up to the next-to-last ! crossing of the value 35. yes? LET salt_next_last = salt* mask_next_last ! Now @LOC:35 points to the last (northernmost) crossing of ! the value 35 within the data. yes? PLOT salt_next_last[Y=@LOC:35]

[Output Graphic]


Last modified: May 17, 2004