[Thread Prev][Thread Next][Index]

Re: [ferret_users] Longitude and latitude of eddy amplitude as variables, how to convert them into axis of the variable amp



Hi Ansley,

I wrote all the scattered data to a single ascii file, and then gridded the ascii file data successfully! Your commands were absolutely fine and had no error. Thanks a ton for this step-by-step guide.
The main problem I had with my data was that it was too sparse and dimensions were not matching for different daily files, due to which I failed to handle this with other methods for weeks. 
Will come up with more questions further in this forum. Thanks alot for the rescue!

On Thu, 13 Feb 2020 at 21:11, Ansley C. Manke <ansley.b.manke@xxxxxxxx> wrote:
Hi,
Yes, you have asked your question with enough information to convey what you want to do.

This is a "scatter-to-grid" kind of operation, and there are several functions that do this:

yes? show function/brief SCAT2GRID*

I would suggest SCAT2GRID_BIN_XYT to use a binning method because it looks as though your data is quite sparse.   The arguments to the SCAT2GRID function are xpts, ypts, tpts, varpts, and variables defining the output grid.

The data in your multiple files needs to be gathered together into variables that are simple lists of points, and you will need to create a variable representing time.  There may be more elegant ways to do this, but sometimes a simple method is easiest.  I would write all of the data to an ascii file.   Here is the idea -



use 20140101.nc
let day = 1 + 0*amplitude
list/file="2014_data.dat"/append/noheader/norow amplitude, longitude, latitude, day
cancel data 1

use 20140102.nc
let day = 2 + 0*amplitude
list/file="2014_data.dat"/append/noheader/norow amplitude, longitude, latitude, day
cancel data 1

...
use 20141231.nc
let day = 365 + 0*amplitude
list/file="2014_data.dat"/append/noheader/norow amplitude, longitude, latitude, day
cancel data 1


The _expression_  "let day = 1+0*amplitude" etc has the effect of defining a  variable "day" on the same grid as "amplitude", with value 1 for file 1, and so on.


Now, you could use a REPEAT loop to process all of the files, using some of the ideas in this thread: https://www.pmel.noaa.gov/maillists/tmap/ferret_users/fu_2017/msg00324.html:

spawn rm 2014_data.dat

! The file are named so that they will be in the correct order. Make a list of them.
let filenames = SPAWN("ls 2014*.nc")

! Loop over list of filenames

repeat/range=1:365/name=in (let filename = filenames[i=`in`] ; \
  define symbol filen = `filename` ; \
  use ($filen) ; \
  let day = `in` + 0*amplitude ; \
  list/append/noheader/norow/file="2014_data.dat" amplitude, longitude, latitude, day;\
  cancel data ($filen) )


Now, read the variables "amplitude, longitude, latitude, day" from this text file as described under "ASCII data".  This will be the case of multiple variables, one dimension.  Then define your output grid with an xaxis, yaxis and taxis; and call the SCAT2GRID_BIN_XYT function.

I haven't run the commands so of course there may be typos - but I hope this gives you the right idea.  List out some of the variables as you go along to see what the commands are doing.

Ansley

On 2/13/2020 3:09 AM, Avimanyu Ray wrote:
Hi all,

This is the first time I'm asking a question in ferret_users group, so please let me know if I could convey my question properly to all.

I have 365 daily files '20140101.nc', '20140102.nc',.....till '20141231.nc'. Each file contains 3 variables:
eddy_amplitude, longitude, and latitude.
Each of these variables have only 1 axis, i.e. J axis.
For example,

    currently SET data sets:
    1> ./20140101.nc  (default)
 name     title                             I         J         K         L
AMPLITUDE                           ...       1:3       ...       ...
LONGITUDE                           ...       1:3       ...       ...
LATITUDE                               ...       1:3       ...       ...

This means that, I have records of amplitudes, longitudes and latitudes of 3 eddies on that day, 01-jan-2014.
Number of eddies are not fixed daily.

I want to make a single annual netcdf file 'eddy.nc' like this:

              currently SET data sets:
    1> eddy.nc  (default)
 name     title                           I            J          K            L
 AMP                                    1:21      1:21      ...       1:365

yes? sh gr AMP
 GRID          MY_GRID
  name             axis           # pts                start                            end              subset
 XAXIX     LONGITUDE    21mr                79E                            99E                   full
 YAXIX     LATITUDE         21 r                  3N                            23N                   full
 normal              Z
 TAXIS            TIME          365 r   01-JAN-2014 12:00    31-DEC-2014 12:00   full



I am not getting any idea how to obtain this resultant file from my daily files.
Also, what to do when my given longitude and latitude coordinates are variables instead of axis.
In case you need ncdump of the given and resultant files, let me know. Please help me through this, as I am new to Ferret. Thanks in advance!

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

Privacy Policy | Disclaimer | Accessibility Statement