[Thread Prev][Thread Next][Index]

Re: [ferret_users] extract a string



Make use of TAX_DATESTRING and SUBSTRING function

Following example may help you


[akshay@localhost tmp]$ ferret
     NOAA/PMEL TMAP
     FERRET v6.93 
     Linux 2.6.32-504.el6.x86_64 64-bit - 11/13/14
     28-Oct-15 13:37    

yes? go test.jnl
 ! NOAA/PMEL TMAP
 ! FERRET v6.93
 ! Linux 2.6.32-504.el6.x86_64 64-bit - 11/13/14
 ! 28-Oct-15 13:20
 
use "http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Ifremer/daily_flux"
 
show d
     currently SET data sets:
    1> http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Ifremer/daily_flux  (default)
 name     title                             I         J         K         L         M         N
 AIRT     air temperature (deg. k)         1:1440    1:720     ...       1:3670    ...       ...
 LHF      surface flux of latent heat (w/  1:1440    1:720     ...       1:3670    ...       ...
 SH       specific humidity (kg/kg)        1:1440    1:720     ...       1:3670    ...       ...
 SHF      surface flux of sensible heat (  1:1440    1:720     ...       1:3670    ...       ...
 SST      sea surface temperature (deg. k  1:1440    1:720     ...       1:3670    ...       ...
 W        wind speed module (m/s)          1:1440    1:720     ...       1:3670    ...       ...
 WSTRESS  wind stress module (pa)          1:1440    1:720     ...       1:3670    ...       ...
 U        u-component of wind (m/s)        1:1440    1:720     ...       1:3670    ...       ...
 USTRESS  u-component of surface wind str  1:1440    1:720     ...       1:3670    ...       ...
 V        v-component of wind (m/s)        1:1440    1:720     ...       1:3670    ...       ...
 VSTRESS  v-component of surface wind str  1:1440    1:720     ...       1:3670    ...       ...
 
 
show g u
    GRID GRS1
 name       axis              # pts   start                end
 LON       LONGITUDE         1440mr   0.25E                0E(360)
 LAT       LATITUDE           720 r   89.75S               90N
 normal    Z
 TIME      TIME              3670 r   01-NOV-1999 00:00    17-NOV-2009 00:00
 normal    E
 normal    F
 
list/l=1 t[g=u]
             VARIABLE : T
                        axis TIME
             DATA SET : ifremer daily turbulent fluxes
             FILENAME : daily_flux
             FILEPATH : http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Ifremer/
             TIME     : 01-NOV-1999 00:00
          730060.
 
show function TAX_DATESTRING
TAX_DATESTRING(A,B,C)
    Returns date string for time axis coordinate values
    A: time steps to convert
    B: variable with reference time axis
    C: output precision (STRING)
 
list/l=1 TAX_DATESTRING(t[g=u],u[l=1],"")
             VARIABLE : TAX_DATESTRING(T[G=U],U[L=1],"")
             DATA SET : ifremer daily turbulent fluxes
             FILENAME : daily_flux
             FILEPATH : http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Ifremer/
             TIME     : 01-NOV-1999 00:00
        "01-NOV-1999 00:00:00"
 
let full_string = TAX_DATESTRING(t[g=u,l=1],u[l=1],"")
 
let newvar1 = substring(full_string,0,11)
let newvar2 = substring(full_string,13,strlen(full_string))
 
list newvar1
             VARIABLE : SUBSTRING(FULL_STRING,0,11)
             DATA SET : ifremer daily turbulent fluxes
             FILENAME : daily_flux
             FILEPATH : http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Ifremer/
             TIME     : 01-NOV-1999 00:00
        "01-NOV-1999"
list newvar2
             VARIABLE : SUBSTRING(FULL_STRING,13,STRLEN(FULL_STRING))
             DATA SET : ifremer daily turbulent fluxes
             FILENAME : daily_flux
             FILEPATH : http://apdrc.soest.hawaii.edu:80/dods/public_data/satellite_product/Ifremer/
             TIME     : 01-NOV-1999 00:00
        "00:00:00"


Regards,
Akshay Hegde
https://about.me/akshay.k.hegde


On Wed, Oct 28, 2015 at 7:17 AM, Ryo Furue <furue@xxxxxxxxxx> wrote:
> I am ploting wave model output and I want to extract the initial date in the
> format dd-mon-yyyy
>
> ? use ... .nc
> ? sh grid u
>     GRID GAY1
>  name       axis              # pts   start                end
>  LON      LONGITUDE       61mr   0E                   160E
>  LAT       LATITUDE           141 r   70S                  70N
>  normal    Z
>  TIME      TIME                20 r   04-OCT-2015 06:00    09-OCT-2015 00:00
>  normal    E
>  normal    F
>
> Now i want to extract the string "04-OCT-2015" and "06:00" and define it to
> a variable so that it can be used in naming the output file as well as in
> the label. How can i do that.

You can use the RETURN mechanism. To see what it does:

   yes? say `u,return=tstart`

There is an extensive description of what information you can get by
the RETURN mechanism in the Ferret manual.

In this way, you get the string "04-OCT-2015 06:00".  Now, I'm not
familiar with how to manipulate strings. . . .

Ryo



>
> Regards,
>
> --
> Gayatri Vani K
> Project Engineer
> Computational Earth Sciences (CES) Group
> Centre for Development of Advanced Computing (CDAC), Pune
> Mobile: +91-9527615716
> Email: gayatrivanik@xxxxxxx

Attachment: test.jnl
Description: Binary data


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

Privacy Policy | Disclaimer | Accessibility Statement