[Thread Prev][Thread Next][Index]

Re: [ferret_users] listing to ASCII file without missing values



Hi -
Here's a way to just list the numbers lon, lat, time, var, skipping any missing data. First make variables which are just big long 1-D lists of the data.  This lists out the time values as well.
! Define ariables containing a 1-D list of the x, y, or t
! value for each location in the grid of var.

LET lon1d = XSEQUENCE(x[gx=var] + 0*y[gy=var] + 0*t[gt=var])
LET lat1d = XSEQUENCE(0*x[gx=var] + y[gy=var] + 0*t[gt=var])
LET tim1d = XSEQUENCE(0*x[gx=var] + 0*y[gy=var] + t[gt=var])

LET varlist = XSEQUENCE(var)

! These definitions mean that wherever varlist is missing
! then lonlist, etc are missing

LET lonlist = IF varlist THEN XSEQUENCE(lon1d)
LET latlist = IF varlist THEN XSEQUENCE(lat1d)
LET timlist = IF varlist THEN XSEQUENCE(tim1d)

! Now compress the variables to skip where var is misssing

LET tvar = COMPRESSI(timlist)
LET lon = COMPRESSI(lonlist)
LET lat = COMPRESSI(latlist)
LET vari = COMPRESSI(varlist)

! List the remaining good data.
LET npts = `vari[i=@ngd]`
LIST/=1:`npts`/FILE=myfile.dat lon,lat,tvar,vari
The way XSEQUENCE works, this will list the data with LON varying fastest, then LAT, then TIME.

Igaratza Fraile wrote:

Dear Ferreters,

 

I would like to suppress the output data that contains missing values when listing to an ASCII file. I have a three dimensional netcdf file which contains plenty of missing values.

Yes? Sh grid my_var

            Name   axis                  #pts      start     end

            XAX      LONGITUDE     111       30W     80E

            YAX      LATITUDE         61        30s       30n

            NORMALl         Z

            TAX                  T          12        1          12

 

I want to have an ASCII file with 3 columns only at the locations with good values of “my_var” (not a missing value): latitude, longitude and the value my_var. I tried to list all the missing values at the end, and then repeat the function for each longitude and month. This works in principle OK, but the problem is that the index (the corresponding longitude) does not coincide anymore with the original value.

 

Yes? List/x=-30/l=1/nohead compressi(my_var)

The ASCII file looks like that:

 

1          /           1:         0.00

2          /           2:         1.12

3          /           3:         2.22

4          /           4:         1.34

5          /           5:         ….

6          /           6:         ….

 

Does anyone know how to list only the good values without losing the longitude and latitude information?

 


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement