[Thread Prev][Thread Next][Index]

Re: [ferret_users] Jason Images



Hi Paula,

The function RESHAPE allows you to skip the step of creating an
intermediate file to build triples. 

You can save intermediate results so that you don't need to have all
files open at the same time.

The attached script should do what you're looking for. I've written a
loop to generate a sequence of LON data but you should be able to adapt
it easily. 

Bom trabalho!

Paulo B. Oliveira
----------------------------------------------------------------------


On Mon, 2011-03-21 at 20:49 +0000, PaulaOCN Nunes wrote:
> 
> Hello Ferret users;
> 
> I attached an example of a netcdf Jason file which I'm working on
> ("JA1_IPR_2PcP334_001_20110125_040633_20110125_050240.nc")
> I'm interested in the sea surface height anomaly (SSHA) and their
> coordinates (lat, lon), but the file comes with all the data in the
> time axis 
> (1 pair of coordinates and a measure of SSHA for each scan of the
> satellite). Here goes the display of the data:
> 
>     1> ./JA1_IPR_2PcP334_001_20110125_040633_20110125_050240.nc
> (default)
>  name     title                             I         J         K
> L
>  LAT      latitude                         ...       ...       ...
> 1:2350
>  LON      longitude                        ...       ...       ...
> 1:2350
>  SSHA     sea surface height anomaly       ...       ...       ...
> 1:2350, etc
> 
> I realize I need to regrid it to the "I" and "J" axis to be able to
> work with it, then, I first tried to regrid the "lat" variable to the
> "I" axis:
> 
> define axis/x=1:2350:1 iaxis
> define grid/x=iaxis gridCOL
> let lat2=lat[g=gridCOL]
> 
> But it didn't show any difference on the grid ferret's display:
> 
> sh grid lat
>     GRID GSF1
>  name       axis              # pts   start                end
>  normal    X
>  normal    Y
>  normal    Z
>  TIME      TIME              2350 i   25-JAN-2011 04:06    25-JAN-2011
> 05:02
> 
> sh grid lat2
>     GRID GSF1
>  name       axis              # pts   start                end
>  normal    X
>  normal    Y
>  normal    Z
>  TIME      TIME              2350 i   25-JAN-2011 04:06    25-JAN-2011
> 05:02
> 
> Second I tried to regrid the "lat" variable, but to a grid with the 3
> axis:
> 
>  define axis/y=1:2350:1 jaxis
>  define axis/t=1:1:1 laxis
>  define grid/x=iaxis/y=jaxis/t=laxis gridCOL_ROW
> let lat3=lat[g=gridCOL_ROW]
> sh grid lat3
>     GRID (G002)
>  name       axis              # pts   start                end
>  normal    X
>  normal    Y
>  normal    Z
>  LAXIS     T                    1 r   1                    1
> 
> ...it was worse, ferret and I got more confused...The only way I could
> work out to give this data a X/Y axis was to save it as a binary:
> 
> list/clobber/format=unformatted/file="jason1.dat" lon,lat,ssha
> 
> ...and open it again:
> 
> define axis/x=1:2350:1 iaxis
> define grid/x=iaxis gridCOL
> file/format=unformatted/grid=gridCOL/var=lon,lat,ssha/col=3
> "jason1.dat"
>   sh da
>     2> ./jason1.dat  (default)
>  name     title                             I         J         K
> L
>  LON      LON
> 1:2350    ...       ...       ...
>  LAT      LAT
> 1:2350    ...       ...       ...
>  SSHA     SSHA
> 1:2350    ...       ...       ...
> 
> Does anyone have an easier way to regrid the data from the "L" axis to
> the "I"/"J" axis?
>  After this, I used the "scat2gridgauss_xy" command to put the
> variables to this global grid:
> 
> !global grid for all Jason's possible tracks:
> define axis/x=0:360:0.052252252/UNIT=degrees xJASON
> define axis/y=-66.15:60.15:0.052252252/UNIT=degrees yJASON
> let
> sshaJASON=scat2gridgauss_xy(lon,lat,ssha,x[gx=xJASON],y[gy=yJASON],0.5, 0.5, 2, 0)
> 
> I ploted these "sshaJASON" variable with "shade", no problems, but
> isn't there a way to the axis recognize the coordinates described by
> the variables "lat" and "lon",
> without the need of the "scat2gridgauss_xy" command?
> Well, this file is one track of the satellite, and I 'd like to join a
> hole cycle of it, which is the sum of 254 files, to do so, I made a
> script in loop, for load and save the 254 binaries files 
> but I'm not able, because Ferret allows until 100 datasets to be
> loaded at the same time:
>  
> repeat/i=1:(numberFILES):1 (\
> list `i`; \
> file/var=ndata "ndata_`i`.txt"; \
> define axis/x=1:`ndata[i=1]`:1 iaxis; \
> ca da 1; \
> define grid/x=iaxis gridTRIPA; \
> let arq= "JASON_`i`.dat"; \
> file/format=unformatted/grid=gridTRIPA/var=lon,lat,ssha/col=3
> "`arq`" ; \
> let
> sshaJASON=scat2gridgauss_xy(lon,lat,ssha,x[gx=xJASON],y[gy=yJASON],0.5, 0.5, 2, 0) ; \
> let sshaJASON`i` = missing(sshaJASON,0); \
> let sobrepoe`i`_ssha=if (sshaJASON NE 0) then (sshaJASON) else
> (sobrepoe`i-1`_ssha[l=1]); \
> )
> let sobrepoe_ssha=sobrepoe(numberFILES)_ssha[l=1]
> set variable/bad=0 sobrepoe_ssha[l=1]
> set memo/size=1000;shade sobrepoe_ssha;go land_hires
> 
> So I tried to cancel the variables ("ca var ssha") at the end of loop,
> but:
> 
> **ERROR: invalid command: can only CANCEL variables you DEFINE SSHA
> ca var ssha
> 
> then I tried to cancel the dataset at the end of loop ("ca da/all" or
> "ca da 1"), but it keep asking for the old variable (SSHA),
> and I'm unabled to use the new variable with the overlappings
> (sobrepoe_ssha):
> 
> !-> REPEAT: I=1
>  !-> list 1
>              VARIABLE : constant
>           1.000
>  !-> SET DATA/EZ/var=ndata
> "/home/paula/Ressurgencia/JASON/c334/ndata_1.txt"
>  !-> define axis/x=1:2350:1 iaxis
> Replacing definition of axis IAXIS
>  !-> DEFINE VARIABLE arq=
> "/home/paula/Ressurgencia/JASON/c334/JASON_1.dat"
>  !-> SET
> DATA/EZ/format=unformatted/grid=gridTRIPA/var=lon,lat,ssha/col=3
> "/home/paula/Ressurgencia/JASON/c334/JASON_1.dat"
>  !-> DEFINE VARIABLE sshaJASON1 = missing(sshaJASON,0)
>  !-> DEFINE VARIABLE sobrepoe1_ssha=if (sshaJASON NE 0) then
> (sshaJASON) else (sobrepoe0_ssha[l=1])
>  
> let sobrepoe_ssha=sobrepoe($cont2)_ssha[l=1]
>  !-> DEFINE VARIABLE sobrepoe_ssha=sobrepoe1_ssha[l=1]
> set variable/bad=0 sobrepoe_ssha[l=1]
>  
> shade sobrepoe_ssha
>  **ERROR: variable unknown or not in data set: SSHA
> shade sobrepoe_ssha
> Command file, command group, or REPEAT execution aborted
> 
> Is there any way to clear the datasets so I'm able to handle with new
> variables?
> 
> Thanks,
> Paula Lamosa Nunes

Attachment: ssha2d.cdf
Description: Cdf file

 ! NOAA/PMEL TMAP
 ! FERRET v6.65  
 ! Linux rh5 (gfortran) 2.6.18-164.11.1.el5 - 11/30/10
 ! 22-Mar-11 10:04     


!------------------------------------------------- lower resolution to speed up
define axis/x=0:360:0.5/UNIT=degrees        xJASON
define axis/y=-66.15:60.15:0.5/UNIT=degrees yJASON

let ssha2d_0 = 1/0*x[gx=xJASON]+y[gy=yJASON]
save/clobber/file=ssha2d.cdf ssha2d_0

!-- for "real" files --------------------
!let nfiles = `spawn("ls JA1*nc | wc -l")`
!repeat/range=1:`nfiles`:1/name=it (\
! use JA1_...`it`....

repeat/range=1:250:1/name=it (\
 use ssha2d;\
 use JA1_IPR_2PcP334_001_20110125_040633_20110125_050240;\
 def ax/x=1:`lon,ret=lend`:1 xnp;\
 let xp  = reshape(lon, x[gx=xnp])+it-1;\
 let yp  = reshape(lat, x[gx=xnp]);\
 let val = reshape(ssha,x[gx=xnp]);\
 let s2g = scat2gridgauss_xy(xp,yp,val,x[gx=xJASON],y[gy=yJASON],0.5, 0.5, 2, 0);\
 let ssha2d_`it` = if s2g then s2g else ssha2d_`it-1`[d=ssha2d];\
 save/clobber/file=ssha2d.cdf ssha2d_`it`;\
 canc data/all; canc var ssha2d_`it`;canc mem/all\
)

use etopo20; shade/pal=bluescale rose
 use ssha2d;\
 shade/ov  ssha2d_250;\

quit

Attachment: ssha2d_mk.jpg
Description: JPEG image


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement