[Thread Prev][Thread Next][Index]

[ferret_users] list variable1 when variable2=year



Dear Ansley,

 

Thanks a lot. It works perfectly! J

 

Now I have a second problem: I want to extract environmental variables at latitude, longitude and times when fishing occurred and list it to a new ASCII file. I have one netCDF file for each simulation year, and one big ASCII file with all fishing events. The ASCII file has 14 columns with year, quarter, latitude, longitude… etc information on it.

I sampled my netCDF file spatially using SAMPLEXY function and then sampling in time (quarter of the year) using SAMPLEL function. The problem is when I apply SAMPLEL function is taking all the “quarter” values in the ASCII file, independent of the year.  I only want to list those values corresponding to the year I´m extracting the values.

The only solution I found was to make a loop specifying the number of lines belonging to each year (see example script for the first two years), and include both SAMPLEL function and LIST/file function within the loop. This could work for small data files, but my ASCII file has more than 200000 lines and I don’t wanna go line by line looking to line numbers and writing then in the script. Does anyone know a more elegant way to do that?

 

Thanks a lot .

 

 

cancel data/all

define axis/x/x=1:207404:1 longax

define grid/x=longax biggrid

 

 

! 1958

use dchl_ORCA2-Levitus_DFS4_1958.nc

file/grid=biggrid/format=delim/var="ID,ocean,year,quarter,fleet,lat,lon,hooks,alb,bft,yft,bet,skj,sbt"/skip=1 fishing_data.dat

 

show data

            currently SET data sets:

            1> .\dchl_ORCA2-levitus_DFS4_1958.nc <default>

Name               title                              I           J          K          L

DCHL               Tracer as simulated…    1:360    1:180    1:31      1:73

 

            2> .\fishing_data.dat

Name   title                              I                       J          K          L

ID                     ID

OCEAN            OCEAN            1:207404          …         …         …

YEAR               YEAR               1:207404          …         …         …

QUARTER        QUARTER        1:207404          …         …         …

FLEET              FLEET              1:207404          …         …         …

LAT                  LON                 1:207404          …         …         …

HOOKS            HOOKS            1:207404          …         …         …

…                    …

 

! Integration between 0-100m depth:

let dchl_k=dchl[d=1,k=1:10@din]

 

! Select latitude and longitude ponts:

let dchl_xy=samplexy(dchl_k,lon[d=2],lat[d=2]) ! Select latitude and longitude ponts

 

!Regridding to 4 time steps:

define axis/t="02-jan-1958 12:00:00":"29-dec-1958 12:00:00"/npoints=4/edges/units=seconds/calendar=noleap secondaxis

let dchl_time=dchl_xy[d=1,gt=secondaxis@ave]

 

!Select the quarter of the year and list it in a new ASCII file:

repeat/I=1:112 (let dchl_xyt=samplel(dchl_time,quarter[d=2]);\

list/nohead/format=(3F16.10)/file="dchl_0-100m_1958-2010.dat"/append year[d=2],dchl_xyt,quarter[d=2])

 

cancel data dchl_ORCA2-Levitus_DFS4_1958.nc

 

!1959

use dchl_ORCA2-Levitus_DFS4_1959.nc

 

let dchl_k=dchl[d=1,k=1:10@din]

let dchl_xy=samplexy(dchl_k,lon[d=2],lat[d=2])

 

define axis/t="02-jan-1959 12:00:00":"29-dec-1959 12:00:00"/npoints=4/edges/units=seconds/calendar=noleap secondaxis

let dchl_time=dchl_xy[d=1,gt=secondaxis@ave]

repeat/I=113:176 (let dchl_xyt=samplel(dchl_time,quarter[d=2]);\

list/nohead/format=(3F16.10)/file="dchl_0-100m_1958-2010.dat"/append year[d=2],dchl_xyt,quarter[d=2])

cancel data dchl_0-100m_1959.nc

 

 

same for each year…

 

 

-Igaratza-


De: Ansley Manke [mailto:ansley.b.manke@xxxxxxxx]
Enviado el: jueves, 30 de mayo de 2013 19:29
Para: Igaratza Fraile
CC: ferret_users@xxxxxxxx
Asunto: Re: [ferret_users] regridding in time

 

Hi,
This is done in Ferret with a regridding operation. Have a look at "regridding" in the documentation. Define the new time axis, and regrid your data to that axis. If you are happy with a regularly-spaced output axis, which will be only approximately the 3-month intervals, you could do it this way:

define axis/t=1-jan-1958:31-dec-1958/npoints=4/edges/units=days  seas_1958
let newDCHL = DCHL[gt=seas_1958]


Or you could look at the documentation under "monthly axis", creating for how to make an axis with time steps that include exactly the months JFM, AMJ, etc.

The other thing you can do is a "climatological regridding".  It sounds as if your data spans less than a year, but if it were several years, what this would do is average all the data in Jan-Feb-Mar into the first timestep, and all the April-May-June,  into the second, etc.  This operation is described in  the section on Climatological, also known as Modulo regridding.

-Ansley

On 5/23/2013 4:50 AM, Igaratza Fraile wrote:

Dear ferreters

 

I´m using a netCDF file for one year with data for every 5 days (73 time steps).

 

yes? Sh da

            currently SET data sets:

            1> .\dchl_ORCA2-levitus_DFS4_1958.nc <default>

Name   title                              I           J          K          L

DCHL   Tracer as simulated…    1:360    1:180    1:31      1:73

 

 I would like to get average values for every 3 month (Jan-Feb-Mar, Apr-may-Jun, Jul-aug-Sep and Oct-Nov-dec). I tried to use @ave transformation, but for some reason the results is not what I expected.

 

yes? let newDCHL=DCHL[L=1:72:18@ave]  (I ignored the last day)

 

However the average value is not the same as 1:18@ave, 19:36@ave…

 

yes? list/i=1/j=1/k=1 DCHL[L=1:18@ave], DCHL[L=1:18:18@ave], newDCHL[L=1]

            DCHL               DCHL               newDCHL

I / *:      1.864E-06         2.644E-06         2.644E-06

 

The value I was expecting is the first one. Why is that difference? And how can I regrid my data to get average values for every three months?

Thanks in advance

_________________________________________________________________________________________



 

Igaratza Fraile
Unidad de investigación Marina
T. +34 667 174 464
Herrera Kaia, Portualdea z/g

E-20110 Pasaia, Gipuzkoa.
Mail: ifraileo@xxxxxxx

 

 

 

 

Descripción: AZTI
                                                en Google+ Descripción: AZTI
                                                en MemolaneDescripción: AZTI
                                                en Vimeo
www.azti.es | www.alimentatec.com | www.itsasnet.com
T. (+34) 94 657 40 00 | 

Fax.(34) 94 657 25 55 

 

 

 

 

 


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

Privacy Policy | Disclaimer | Accessibility Statement