[Thread Prev][Thread Next][Index]

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



Thanks Ansley for the help. In principle, it works well and I have now my variable in an ASCII file without the missing values. However, the latitudes and longitudes do not coincide with the original value.

For example, using the original netcdf file:

 

Yes? List/x=70:75/y=-11/l=1 my_var

                        11S

70E      / 101:    13.6

71E      / 102:    0.0

72E      / 103:    5.8

73E      / 104:    3.0

74E      / 105:    0.0

75E      / 106:    0.0

 

In the ASCII file  these values correspond to another coordinates

                        LON     LAT      TVAR   VARI   

4          / 4:       70.00    -11.00   1.00      13.6

5          / 5:       72.00    -11.00   1.00      0.0

6          / 6:       73.00    -11.00   1.00      5.8

7          / 7:       22.00    -10.00   1.00      3.0

8          / 8:       23.00    -10.00   1.00      0.0

9          / 9:       40.00    -10.00   1.00      0.0

 

 

The error starts happening in the first 0.0 value of my_var. I figured out that the solution is very simple and would like to include here, as it may be useful for other ferreters.  Just adding “GT -1” to the conditional commands it works without problems:

 

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

 

Igaratza

 


De: Ansley Manke [mailto:Ansley.B.Manke@xxxxxxxx]
Enviado el: viernes, 22 de mayo de 2009 22:35
Para: Igaratza Fraile
CC: oar.pmel.ferret_users@xxxxxxxx
Asunto: 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