Call the functions SORTI, SORTJ, SORTK, SORTL to obtain lists of indices ofsorted data
Call the functions SAMPLEI, SAMPLEJ, SAMPLEK, SAMPLEL to sample data at a listof indices
A first simple example of sorting: Sort a list of data. Use COADSsea surface data at a location where some of the data is missing.These are grid-changing functions so specify the region of the argumentsin square brackets.
yes? USE coads_climatology yes? LIST sst[x=19e,y=77n,l=1:6] SEA SURFACE TEMPERATURE (Deg C) LATITUDE: 77N DATA SET: /opt/local/ferret/fer_dsets/descr/coads_climatology.des 19E 0 16-JAN / 1: 0.300 15-FEB / 2: .... 17-MAR / 3: .... 16-APR / 4: 5.000 16-MAY / 5: 1.350 16-JUN / 6: 2.799
The sequence of calls is: Compute the sorted indices, thensample the data using the new order of indices.
Show the indices and the sorted temperatures
yes? LET tsorted_indices = sortl(sst[x=19e,y=77n,l=1:6]) yes? LET tsorted_sst = samplel(sst[x=19e,y=77n,l=1:6], tsorted_indices) yes? LIST tsorted_indices, tsorted_sst DATA SET: /opt/local/ferret/fer_dsets/descr/coads_climatology.des COADS Monthly Climatology (1946-1989) T: 0.5 to 6.5 LONGITUDE: 19E LATITUDE: 77N Column 1: TSORTED_INDICES is SORTL(SST[X=19E,Y=77N,L=1:6]) Column 2: TSORTED_SST is SAMPLEL(SST[X=19E,Y=77N,L=1:6], TSORTED_INDICES) TSORTED_TSORTED_ 1 / 1: 1.000 0.300 2 / 2: 5.000 1.350 3 / 3: 6.000 2.799 4 / 4: 4.000 5.000 5 / 5: .... .... 6 / 6: .... ....
We can also use the constant-array notation to pick out a coupleof points, the first and fifth SST value in the list.
yes? LIST samplel(sst[x=19e,y=77n,l=1:6], {1,5}) yes? LIST samplel(sst[x=19e,y=77n,l=1:6], {1,5}) SAMPLEL(SST[X=19E,Y=77N,L=1:6], {1,5}) LATITUDE: 77N DATA SET: /opt/local/ferret/fer_dsets/descr/coads_climatology.des 19E 0 1 / 1: 0.300 2 / 2: 1.350
Now a more involved example: What is the Sea Surface Temperaturein a region three months after the strongest winds in anotherregion? Use the COADS monthly climatology data set. Choose a region in the Pacific, and define the westerly_wind variableto be the monthly west winds averaged over this region. Sort thewesterly winds, lowest to highest. "sorted_indices3"is the indices 3 months after.
yes? LET westerly_wind = uwnd[x=160e:180@ave,y=35n:45n@ave] yes? LET sst_e = sst[x=180:80w@ave,y=35n:45n@ave] yes? LET sorted_indices = sortl(westerly_wind)yes? LET sorted_indices3 = MOD((sorted_indices + 2), 12) + 1
We will plot sorted winds vs the SST's, three monthslater, and in the other region. First sample the westerly windsby their sorted indices. Then order the SST's according to thesorted wind indices plus 3 months.
yes? LET wwe_by_wwe = samplel(westerly_wind,sorted_indices) yes? LET sst_by_wwe = samplel(sst_e, sorted_indices3)
The SST's of interest are to the east of our westerly_wind region.Get the number of valid data in the sort.
yes? LET leng = wwe_by_wwe[l=@NGD]
Make a scatter plots: sampled winds vs SST, using the PLOT/VS/RIBBON style to color the symbols by the magnitude of the winds
yes? SET VAR/TITLE="Sorted Westerly Winds from 160E to 180" wwe_by_ww yes? SET VAR/TITLE="SST from 180 to 80W 3 months after Westerly winds" sst_by_wwe yes? PLOT/VS/RIBBON/THICK/SYM=18/TITLE="SST 3 months after High Westerly Winds, colored by Wind"\ /pal=blue_purple_orange/hlim=0:5.5/l=1:`leng` wwe_by_wwe, sst_by_wwe, wwe_by_wwe