[Met_help] [rt.rap.ucar.edu #58112] History for Question about trmm2nc.R

John Halley Gotway via RT met_help at ucar.edu
Fri Sep 7 13:00:26 MDT 2012


----------------------------------------------------------------
  Initial Request
----------------------------------------------------------------

Dear met_help,
I am working with trmm 24 hours data to compare with our WRF results.
I processed trmm2nc with the version included in METv3.1
I send you the ncdump of  the nc file generated by R,where there is no
information about init and valid time.

 dimensions:
        lon = 49 ;
        lat = 41 ;
variables:
        double lon(lon) ;
                lon:units = "degrees_east" ;
                lon:long_name = "lon" ;
        double lat(lat) ;
                lat:units = "degrees_north" ;
                lat:long_name = "lat" ;
        float APCP_NA(lat, lon) ;
                APCP_NA:units = "kg/m^2" ;
                APCP_NA:_FillValue = -9999.f ;
                APCP_NA:long_name = "Total precipitation" ;
                APCP_NA:name = "APCP" ;
                APCP_NA:level = "ANA" ;
                APCP_NA:grib_code = 61. ;
                APCP_NA:init_time = "NA" ;
                APCP_NA:init_time_ut = NaN ;
                APCP_NA:valid_time = "NA" ;
                APCP_NA:valid_time_ut = NaN ;
                APCP_NA:accum_time = "NA0000" ;
                APCP_NA:accum_time_sec = NaN ;


In other hand, It is not clear the following script instructions.In
particular why 22.5 is substracted from the end date.
Thanks for your help,
Gisela


if(acc_type == 03) {



  # For 03-hour accumulations, the time stamp gives the middle of the  #
accumulation interval.
  # Subtract 1.5 hours from the begin timestamp to get the init time.
  # Add 1.5 hours to the end timestamp to get the valid time.

  init  = as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
'-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)

  valid = as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
'-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)



} else {



  # The 24-hour accumulations are actually a sum of 03-hour accumulations:

  #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z

  # Subtract 1.5 hours from the begin date to get the init time.

  # Add 22.5 hours to the end date to get the valid time.



  init  = as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
'-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)

  valid = as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
'-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)

}



# Compute the accumulation interval

acc_sec =  as.double(valid - init, units="secs")

acc_hr  = floor(acc_sec / 3600)

acc_str = sprintf("%.2i", acc_hr)


----------------------------------------------------------------
  Complete Ticket History
----------------------------------------------------------------

Subject: Re: [rt.rap.ucar.edu #58112] Question about trmm2nc.R
From: John Halley Gotway
Time: Wed Sep 05 11:25:12 2012

Gisela,

I stepped through the process of retrieving TRMM data from the NASA
website and running it through the trmm2nc.R script.  But I was unable
to reproduce the problem you describe.  However, I did find a
small issue in the Rscript when checking if the data is 3-hourly or
24-hourly.  I've corrected that and updated the version of trmm2nc.R
on the MET website.

Please try going through the following steps to see if the issue is
resolved:

(1) Download some TRMM data in ASCII format...
  - The MET website lists links to this data
(http://www.dtcenter.org/met/users/downloads/observation_data.php)
  - For 3-hourly data:
http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42.shtml
  - For 24-hourly data:
http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.shtml

    On the NASA site, make sure that "Accumulated Rainfall" is
selected, choose your lat/lon region of interest, and choose your
dates of interest.
    Then click the "ASCII Output" button.
    Save the resulting ASCII data to a file locally.

(2) Pull down the updated version of the trmm2nc.R script:
    http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R

(3) Run the data you pulled through the trmm2nc.R script.
    Rscript trmm2nc.R data.ascii data.nc

(4) View the resulting data using either "ncview", Unidata's IDV
program, or MET's plot_data_plane utility.

Do those step work for you, or are you still experiencing problems?

Thanks,
John Halley Gotway
met_help at ucar.edu


On 09/05/2012 10:40 AM, Gisela Daniela Charó via RT wrote:
>
> Wed Sep 05 10:40:16 2012: Request 58112 was acted upon.
> Transaction: Ticket created by charogiselad at gmail.com
>         Queue: met_help
>       Subject: Question about trmm2nc.R
>         Owner: Nobody
>    Requestors: charogiselad at gmail.com
>        Status: new
>   Ticket <URL:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
>
>
> Dear met_help,
> I am working with trmm 24 hours data to compare with our WRF
results.
> I processed trmm2nc with the version included in METv3.1
> I send you the ncdump of  the nc file generated by R,where there is
no
> information about init and valid time.
>
>   dimensions:
>          lon = 49 ;
>          lat = 41 ;
> variables:
>          double lon(lon) ;
>                  lon:units = "degrees_east" ;
>                  lon:long_name = "lon" ;
>          double lat(lat) ;
>                  lat:units = "degrees_north" ;
>                  lat:long_name = "lat" ;
>          float APCP_NA(lat, lon) ;
>                  APCP_NA:units = "kg/m^2" ;
>                  APCP_NA:_FillValue = -9999.f ;
>                  APCP_NA:long_name = "Total precipitation" ;
>                  APCP_NA:name = "APCP" ;
>                  APCP_NA:level = "ANA" ;
>                  APCP_NA:grib_code = 61. ;
>                  APCP_NA:init_time = "NA" ;
>                  APCP_NA:init_time_ut = NaN ;
>                  APCP_NA:valid_time = "NA" ;
>                  APCP_NA:valid_time_ut = NaN ;
>                  APCP_NA:accum_time = "NA0000" ;
>                  APCP_NA:accum_time_sec = NaN ;
>
>
> In other hand, It is not clear the following script instructions.In
> particular why 22.5 is substracted from the end date.
> Thanks for your help,
> Gisela
>
>
> if(acc_type == 03) {
>
>
>
>    # For 03-hour accumulations, the time stamp gives the middle of
the  #
> accumulation interval.
>    # Subtract 1.5 hours from the begin timestamp to get the init
time.
>    # Add 1.5 hours to the end timestamp to get the valid time.
>
>    init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> '-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
>
>    valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> '-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)
>
>
>
> } else {
>
>
>
>    # The 24-hour accumulations are actually a sum of 03-hour
accumulations:
>
>    #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z
>
>    # Subtract 1.5 hours from the begin date to get the init time.
>
>    # Add 22.5 hours to the end date to get the valid time.
>
>
>
>    init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> '-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
>
>    valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> '-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)
>
> }
>
>
>
> # Compute the accumulation interval
>
> acc_sec =  as.double(valid - init, units="secs")
>
> acc_hr  = floor(acc_sec / 3600)
>
> acc_str = sprintf("%.2i", acc_hr)
>


------------------------------------------------
Subject: Question about trmm2nc.R
From: Gisela Daniela Charó
Time: Thu Sep 06 07:40:38 2012

Hi John,
I followed that steps,when I got the 24-hourly data ascii file on the
NASA
website , on the header of the file there was :

Selected parameter: Daily TRMM 3B42(V7) Accumulated Rainfall
Selected area: lat=[50S,0], lon=[85W,35W]
Selected time period: (24Oct2011-25Oct2011)
Undefined/Missing Value: -9999.9
Unit: (mm)


When I run trmm2nc.R , I got this message:

ERROR: Can't figure out the accumulation interval!

So, I  changed  this part of the script, instead of TRMM I put Daily,
and
it works!

# Determine the accumlation interval
if(as.character(hdr[1,3]) == "TRMM") {
  acc_type = 24
} else if(as.character(hdr[1,3]) == "3-hourly") {
  acc_type = 3
} else {
  cat("\n\nERROR: Can\'t figure out the accumulation interval!\n\n")
  exit(1)
}
# Determine the accumlation interval
if(as.character(hdr[1,3]) == "Daily") {
  acc_type = 24
} else if(as.character(hdr[1,3]) == "3-hourly") {
  acc_type = 3
} else {
  cat("\n\nERROR: Can\'t figure out the accumulation interval!\n\n")
  exit(1)
}

Thanks for your help!
Gisela





2012/9/5 John Halley Gotway via RT <met_help at ucar.edu>

> Gisela,
>
> I stepped through the process of retrieving TRMM data from the NASA
> website and running it through the trmm2nc.R script.  But I was
unable to
> reproduce the problem you describe.  However, I did find a
> small issue in the Rscript when checking if the data is 3-hourly or
> 24-hourly.  I've corrected that and updated the version of trmm2nc.R
on the
> MET website.
>
> Please try going through the following steps to see if the issue is
> resolved:
>
> (1) Download some TRMM data in ASCII format...
>   - The MET website lists links to this data (
> http://www.dtcenter.org/met/users/downloads/observation_data.php)
>   - For 3-hourly data:
> http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42.shtml
>   - For 24-hourly data:
> http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.shtml
>
>     On the NASA site, make sure that "Accumulated Rainfall" is
selected,
> choose your lat/lon region of interest, and choose your dates of
interest.
>     Then click the "ASCII Output" button.
>     Save the resulting ASCII data to a file locally.
>
> (2) Pull down the updated version of the trmm2nc.R script:
>     http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
>
> (3) Run the data you pulled through the trmm2nc.R script.
>     Rscript trmm2nc.R data.ascii data.nc
>
> (4) View the resulting data using either "ncview", Unidata's IDV
program,
> or MET's plot_data_plane utility.
>
> Do those step work for you, or are you still experiencing problems?
>
> Thanks,
> John Halley Gotway
> met_help at ucar.edu
>
>
> On 09/05/2012 10:40 AM, Gisela Daniela Charó via RT wrote:
> >
> > Wed Sep 05 10:40:16 2012: Request 58112 was acted upon.
> > Transaction: Ticket created by charogiselad at gmail.com
> >         Queue: met_help
> >       Subject: Question about trmm2nc.R
> >         Owner: Nobody
> >    Requestors: charogiselad at gmail.com
> >        Status: new
> >   Ticket <URL:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
> >
> >
> > Dear met_help,
> > I am working with trmm 24 hours data to compare with our WRF
results.
> > I processed trmm2nc with the version included in METv3.1
> > I send you the ncdump of  the nc file generated by R,where there
is no
> > information about init and valid time.
> >
> >   dimensions:
> >          lon = 49 ;
> >          lat = 41 ;
> > variables:
> >          double lon(lon) ;
> >                  lon:units = "degrees_east" ;
> >                  lon:long_name = "lon" ;
> >          double lat(lat) ;
> >                  lat:units = "degrees_north" ;
> >                  lat:long_name = "lat" ;
> >          float APCP_NA(lat, lon) ;
> >                  APCP_NA:units = "kg/m^2" ;
> >                  APCP_NA:_FillValue = -9999.f ;
> >                  APCP_NA:long_name = "Total precipitation" ;
> >                  APCP_NA:name = "APCP" ;
> >                  APCP_NA:level = "ANA" ;
> >                  APCP_NA:grib_code = 61. ;
> >                  APCP_NA:init_time = "NA" ;
> >                  APCP_NA:init_time_ut = NaN ;
> >                  APCP_NA:valid_time = "NA" ;
> >                  APCP_NA:valid_time_ut = NaN ;
> >                  APCP_NA:accum_time = "NA0000" ;
> >                  APCP_NA:accum_time_sec = NaN ;
> >
> >
> > In other hand, It is not clear the following script
instructions.In
> > particular why 22.5 is substracted from the end date.
> > Thanks for your help,
> > Gisela
> >
> >
> > if(acc_type == 03) {
> >
> >
> >
> >    # For 03-hour accumulations, the time stamp gives the middle of
the  #
> > accumulation interval.
> >    # Subtract 1.5 hours from the begin timestamp to get the init
time.
> >    # Add 1.5 hours to the end timestamp to get the valid time.
> >
> >    init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> > '-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
> >
> >    valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> > '-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)
> >
> >
> >
> > } else {
> >
> >
> >
> >    # The 24-hour accumulations are actually a sum of 03-hour
> accumulations:
> >
> >    #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z
> >
> >    # Subtract 1.5 hours from the begin date to get the init time.
> >
> >    # Add 22.5 hours to the end date to get the valid time.
> >
> >
> >
> >    init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> > '-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
> >
> >    valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> > '-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)
> >
> > }
> >
> >
> >
> > # Compute the accumulation interval
> >
> > acc_sec =  as.double(valid - init, units="secs")
> >
> > acc_hr  = floor(acc_sec / 3600)
> >
> > acc_str = sprintf("%.2i", acc_hr)
> >
>
>
>

------------------------------------------------
Subject: Re: [rt.rap.ucar.edu #58112] Question about trmm2nc.R
From: John Halley Gotway
Time: Thu Sep 06 08:58:50 2012

Gisela,

Yes, the change you describe is exactly the change I made to the
trmm2nc.R script posted on the MET website:
    http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R

That's why I asked you to pull down the updated version of that
script.  But I am very glad to hear that it is now working for you.

Just let us know if more issues arise in your use of MET.

Thanks,
John

On 09/06/2012 07:40 AM, Gisela Daniela Charó via RT wrote:
>
> <URL: https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
>
> Hi John,
> I followed that steps,when I got the 24-hourly data ascii file on
the NASA
> website , on the header of the file there was :
>
> Selected parameter: Daily TRMM 3B42(V7) Accumulated Rainfall
> Selected area: lat=[50S,0], lon=[85W,35W]
> Selected time period: (24Oct2011-25Oct2011)
> Undefined/Missing Value: -9999.9
> Unit: (mm)
>
>
> When I run trmm2nc.R , I got this message:
>
> ERROR: Can't figure out the accumulation interval!
>
> So, I  changed  this part of the script, instead of TRMM I put
Daily, and
> it works!
>
> # Determine the accumlation interval
> if(as.character(hdr[1,3]) == "TRMM") {
>    acc_type = 24
> } else if(as.character(hdr[1,3]) == "3-hourly") {
>    acc_type = 3
> } else {
>    cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
>    exit(1)
> }
> # Determine the accumlation interval
> if(as.character(hdr[1,3]) == "Daily") {
>    acc_type = 24
> } else if(as.character(hdr[1,3]) == "3-hourly") {
>    acc_type = 3
> } else {
>    cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
>    exit(1)
> }
>
> Thanks for your help!
> Gisela
>
>
>
>
>
> 2012/9/5 John Halley Gotway via RT <met_help at ucar.edu>
>
>> Gisela,
>>
>> I stepped through the process of retrieving TRMM data from the NASA
>> website and running it through the trmm2nc.R script.  But I was
unable to
>> reproduce the problem you describe.  However, I did find a
>> small issue in the Rscript when checking if the data is 3-hourly or
>> 24-hourly.  I've corrected that and updated the version of
trmm2nc.R on the
>> MET website.
>>
>> Please try going through the following steps to see if the issue is
>> resolved:
>>
>> (1) Download some TRMM data in ASCII format...
>>    - The MET website lists links to this data (
>> http://www.dtcenter.org/met/users/downloads/observation_data.php)
>>    - For 3-hourly data:
>> http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42.shtml
>>    - For 24-hourly data:
>>
http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.shtml
>>
>>      On the NASA site, make sure that "Accumulated Rainfall" is
selected,
>> choose your lat/lon region of interest, and choose your dates of
interest.
>>      Then click the "ASCII Output" button.
>>      Save the resulting ASCII data to a file locally.
>>
>> (2) Pull down the updated version of the trmm2nc.R script:
>>      http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
>>
>> (3) Run the data you pulled through the trmm2nc.R script.
>>      Rscript trmm2nc.R data.ascii data.nc
>>
>> (4) View the resulting data using either "ncview", Unidata's IDV
program,
>> or MET's plot_data_plane utility.
>>
>> Do those step work for you, or are you still experiencing problems?
>>
>> Thanks,
>> John Halley Gotway
>> met_help at ucar.edu
>>
>>
>> On 09/05/2012 10:40 AM, Gisela Daniela Charó via RT wrote:
>>>
>>> Wed Sep 05 10:40:16 2012: Request 58112 was acted upon.
>>> Transaction: Ticket created by charogiselad at gmail.com
>>>          Queue: met_help
>>>        Subject: Question about trmm2nc.R
>>>          Owner: Nobody
>>>     Requestors: charogiselad at gmail.com
>>>         Status: new
>>>    Ticket <URL:
https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
>>>
>>>
>>> Dear met_help,
>>> I am working with trmm 24 hours data to compare with our WRF
results.
>>> I processed trmm2nc with the version included in METv3.1
>>> I send you the ncdump of  the nc file generated by R,where there
is no
>>> information about init and valid time.
>>>
>>>    dimensions:
>>>           lon = 49 ;
>>>           lat = 41 ;
>>> variables:
>>>           double lon(lon) ;
>>>                   lon:units = "degrees_east" ;
>>>                   lon:long_name = "lon" ;
>>>           double lat(lat) ;
>>>                   lat:units = "degrees_north" ;
>>>                   lat:long_name = "lat" ;
>>>           float APCP_NA(lat, lon) ;
>>>                   APCP_NA:units = "kg/m^2" ;
>>>                   APCP_NA:_FillValue = -9999.f ;
>>>                   APCP_NA:long_name = "Total precipitation" ;
>>>                   APCP_NA:name = "APCP" ;
>>>                   APCP_NA:level = "ANA" ;
>>>                   APCP_NA:grib_code = 61. ;
>>>                   APCP_NA:init_time = "NA" ;
>>>                   APCP_NA:init_time_ut = NaN ;
>>>                   APCP_NA:valid_time = "NA" ;
>>>                   APCP_NA:valid_time_ut = NaN ;
>>>                   APCP_NA:accum_time = "NA0000" ;
>>>                   APCP_NA:accum_time_sec = NaN ;
>>>
>>>
>>> In other hand, It is not clear the following script
instructions.In
>>> particular why 22.5 is substracted from the end date.
>>> Thanks for your help,
>>> Gisela
>>>
>>>
>>> if(acc_type == 03) {
>>>
>>>
>>>
>>>     # For 03-hour accumulations, the time stamp gives the middle
of the  #
>>> accumulation interval.
>>>     # Subtract 1.5 hours from the begin timestamp to get the init
time.
>>>     # Add 1.5 hours to the end timestamp to get the valid time.
>>>
>>>     init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>> '-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
>>>
>>>     valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>> '-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)
>>>
>>>
>>>
>>> } else {
>>>
>>>
>>>
>>>     # The 24-hour accumulations are actually a sum of 03-hour
>> accumulations:
>>>
>>>     #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z
>>>
>>>     # Subtract 1.5 hours from the begin date to get the init time.
>>>
>>>     # Add 22.5 hours to the end date to get the valid time.
>>>
>>>
>>>
>>>     init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>> '-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
>>>
>>>     valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>> '-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)
>>>
>>> }
>>>
>>>
>>>
>>> # Compute the accumulation interval
>>>
>>> acc_sec =  as.double(valid - init, units="secs")
>>>
>>> acc_hr  = floor(acc_sec / 3600)
>>>
>>> acc_str = sprintf("%.2i", acc_hr)
>>>
>>
>>
>>


------------------------------------------------
Subject: Question about trmm2nc.R
From: Gisela Daniela Charó
Time: Thu Sep 06 09:07:42 2012

Hi John, I download that version on that link, but it the same as the
older
version, isn´t it?
Thanks!
Gisela

2012/9/6 John Halley Gotway via RT <met_help at ucar.edu>

> Gisela,
>
> Yes, the change you describe is exactly the change I made to the
trmm2nc.R
> script posted on the MET website:
>     http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
>
> That's why I asked you to pull down the updated version of that
script.
>  But I am very glad to hear that it is now working for you.
>
> Just let us know if more issues arise in your use of MET.
>
> Thanks,
> John
>
> On 09/06/2012 07:40 AM, Gisela Daniela Charó via RT wrote:
> >
> > <URL: https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
> >
> > Hi John,
> > I followed that steps,when I got the 24-hourly data ascii file on
the
> NASA
> > website , on the header of the file there was :
> >
> > Selected parameter: Daily TRMM 3B42(V7) Accumulated Rainfall
> > Selected area: lat=[50S,0], lon=[85W,35W]
> > Selected time period: (24Oct2011-25Oct2011)
> > Undefined/Missing Value: -9999.9
> > Unit: (mm)
> >
> >
> > When I run trmm2nc.R , I got this message:
> >
> > ERROR: Can't figure out the accumulation interval!
> >
> > So, I  changed  this part of the script, instead of TRMM I put
Daily, and
> > it works!
> >
> > # Determine the accumlation interval
> > if(as.character(hdr[1,3]) == "TRMM") {
> >    acc_type = 24
> > } else if(as.character(hdr[1,3]) == "3-hourly") {
> >    acc_type = 3
> > } else {
> >    cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
> >    exit(1)
> > }
> > # Determine the accumlation interval
> > if(as.character(hdr[1,3]) == "Daily") {
> >    acc_type = 24
> > } else if(as.character(hdr[1,3]) == "3-hourly") {
> >    acc_type = 3
> > } else {
> >    cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
> >    exit(1)
> > }
> >
> > Thanks for your help!
> > Gisela
> >
> >
> >
> >
> >
> > 2012/9/5 John Halley Gotway via RT <met_help at ucar.edu>
> >
> >> Gisela,
> >>
> >> I stepped through the process of retrieving TRMM data from the
NASA
> >> website and running it through the trmm2nc.R script.  But I was
unable
> to
> >> reproduce the problem you describe.  However, I did find a
> >> small issue in the Rscript when checking if the data is 3-hourly
or
> >> 24-hourly.  I've corrected that and updated the version of
trmm2nc.R on
> the
> >> MET website.
> >>
> >> Please try going through the following steps to see if the issue
is
> >> resolved:
> >>
> >> (1) Download some TRMM data in ASCII format...
> >>    - The MET website lists links to this data (
> >> http://www.dtcenter.org/met/users/downloads/observation_data.php)
> >>    - For 3-hourly data:
> >> http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42.shtml
> >>    - For 24-hourly data:
> >>
http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.shtml
> >>
> >>      On the NASA site, make sure that "Accumulated Rainfall" is
> selected,
> >> choose your lat/lon region of interest, and choose your dates of
> interest.
> >>      Then click the "ASCII Output" button.
> >>      Save the resulting ASCII data to a file locally.
> >>
> >> (2) Pull down the updated version of the trmm2nc.R script:
> >>
http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
> >>
> >> (3) Run the data you pulled through the trmm2nc.R script.
> >>      Rscript trmm2nc.R data.ascii data.nc
> >>
> >> (4) View the resulting data using either "ncview", Unidata's IDV
> program,
> >> or MET's plot_data_plane utility.
> >>
> >> Do those step work for you, or are you still experiencing
problems?
> >>
> >> Thanks,
> >> John Halley Gotway
> >> met_help at ucar.edu
> >>
> >>
> >> On 09/05/2012 10:40 AM, Gisela Daniela Charó via RT wrote:
> >>>
> >>> Wed Sep 05 10:40:16 2012: Request 58112 was acted upon.
> >>> Transaction: Ticket created by charogiselad at gmail.com
> >>>          Queue: met_help
> >>>        Subject: Question about trmm2nc.R
> >>>          Owner: Nobody
> >>>     Requestors: charogiselad at gmail.com
> >>>         Status: new
> >>>    Ticket <URL:
> https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
> >>>
> >>>
> >>> Dear met_help,
> >>> I am working with trmm 24 hours data to compare with our WRF
results.
> >>> I processed trmm2nc with the version included in METv3.1
> >>> I send you the ncdump of  the nc file generated by R,where there
is no
> >>> information about init and valid time.
> >>>
> >>>    dimensions:
> >>>           lon = 49 ;
> >>>           lat = 41 ;
> >>> variables:
> >>>           double lon(lon) ;
> >>>                   lon:units = "degrees_east" ;
> >>>                   lon:long_name = "lon" ;
> >>>           double lat(lat) ;
> >>>                   lat:units = "degrees_north" ;
> >>>                   lat:long_name = "lat" ;
> >>>           float APCP_NA(lat, lon) ;
> >>>                   APCP_NA:units = "kg/m^2" ;
> >>>                   APCP_NA:_FillValue = -9999.f ;
> >>>                   APCP_NA:long_name = "Total precipitation" ;
> >>>                   APCP_NA:name = "APCP" ;
> >>>                   APCP_NA:level = "ANA" ;
> >>>                   APCP_NA:grib_code = 61. ;
> >>>                   APCP_NA:init_time = "NA" ;
> >>>                   APCP_NA:init_time_ut = NaN ;
> >>>                   APCP_NA:valid_time = "NA" ;
> >>>                   APCP_NA:valid_time_ut = NaN ;
> >>>                   APCP_NA:accum_time = "NA0000" ;
> >>>                   APCP_NA:accum_time_sec = NaN ;
> >>>
> >>>
> >>> In other hand, It is not clear the following script
instructions.In
> >>> particular why 22.5 is substracted from the end date.
> >>> Thanks for your help,
> >>> Gisela
> >>>
> >>>
> >>> if(acc_type == 03) {
> >>>
> >>>
> >>>
> >>>     # For 03-hour accumulations, the time stamp gives the middle
of
> the  #
> >>> accumulation interval.
> >>>     # Subtract 1.5 hours from the begin timestamp to get the
init time.
> >>>     # Add 1.5 hours to the end timestamp to get the valid time.
> >>>
> >>>     init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>> '-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
> >>>
> >>>     valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>> '-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)
> >>>
> >>>
> >>>
> >>> } else {
> >>>
> >>>
> >>>
> >>>     # The 24-hour accumulations are actually a sum of 03-hour
> >> accumulations:
> >>>
> >>>     #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z
> >>>
> >>>     # Subtract 1.5 hours from the begin date to get the init
time.
> >>>
> >>>     # Add 22.5 hours to the end date to get the valid time.
> >>>
> >>>
> >>>
> >>>     init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>> '-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
> >>>
> >>>     valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>> '-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)
> >>>
> >>> }
> >>>
> >>>
> >>>
> >>> # Compute the accumulation interval
> >>>
> >>> acc_sec =  as.double(valid - init, units="secs")
> >>>
> >>> acc_hr  = floor(acc_sec / 3600)
> >>>
> >>> acc_str = sprintf("%.2i", acc_hr)
> >>>
> >>
> >>
> >>
>
>
>

------------------------------------------------
Subject: Re: [rt.rap.ucar.edu #58112] Question about trmm2nc.R
From: John Halley Gotway
Time: Thu Sep 06 11:11:16 2012

Gisela,

Where it used to say "TRMM", it now says "Daily":

    # Determine the accumlation interval
    if(as.character(hdr[1,3]) == "Daily") {

That was the source of the problem you ran into.

John

On 09/06/2012 09:07 AM, Gisela Daniela Charó via RT wrote:
>
> <URL: https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
>
> Hi John, I download that version on that link, but it the same as
the older
> version, isn´t it?
> Thanks!
> Gisela
>
> 2012/9/6 John Halley Gotway via RT <met_help at ucar.edu>
>
>> Gisela,
>>
>> Yes, the change you describe is exactly the change I made to the
trmm2nc.R
>> script posted on the MET website:
>>      http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
>>
>> That's why I asked you to pull down the updated version of that
script.
>>   But I am very glad to hear that it is now working for you.
>>
>> Just let us know if more issues arise in your use of MET.
>>
>> Thanks,
>> John
>>
>> On 09/06/2012 07:40 AM, Gisela Daniela Charó via RT wrote:
>>>
>>> <URL: https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
>>>
>>> Hi John,
>>> I followed that steps,when I got the 24-hourly data ascii file on
the
>> NASA
>>> website , on the header of the file there was :
>>>
>>> Selected parameter: Daily TRMM 3B42(V7) Accumulated Rainfall
>>> Selected area: lat=[50S,0], lon=[85W,35W]
>>> Selected time period: (24Oct2011-25Oct2011)
>>> Undefined/Missing Value: -9999.9
>>> Unit: (mm)
>>>
>>>
>>> When I run trmm2nc.R , I got this message:
>>>
>>> ERROR: Can't figure out the accumulation interval!
>>>
>>> So, I  changed  this part of the script, instead of TRMM I put
Daily, and
>>> it works!
>>>
>>> # Determine the accumlation interval
>>> if(as.character(hdr[1,3]) == "TRMM") {
>>>     acc_type = 24
>>> } else if(as.character(hdr[1,3]) == "3-hourly") {
>>>     acc_type = 3
>>> } else {
>>>     cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
>>>     exit(1)
>>> }
>>> # Determine the accumlation interval
>>> if(as.character(hdr[1,3]) == "Daily") {
>>>     acc_type = 24
>>> } else if(as.character(hdr[1,3]) == "3-hourly") {
>>>     acc_type = 3
>>> } else {
>>>     cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
>>>     exit(1)
>>> }
>>>
>>> Thanks for your help!
>>> Gisela
>>>
>>>
>>>
>>>
>>>
>>> 2012/9/5 John Halley Gotway via RT <met_help at ucar.edu>
>>>
>>>> Gisela,
>>>>
>>>> I stepped through the process of retrieving TRMM data from the
NASA
>>>> website and running it through the trmm2nc.R script.  But I was
unable
>> to
>>>> reproduce the problem you describe.  However, I did find a
>>>> small issue in the Rscript when checking if the data is 3-hourly
or
>>>> 24-hourly.  I've corrected that and updated the version of
trmm2nc.R on
>> the
>>>> MET website.
>>>>
>>>> Please try going through the following steps to see if the issue
is
>>>> resolved:
>>>>
>>>> (1) Download some TRMM data in ASCII format...
>>>>     - The MET website lists links to this data (
>>>> http://www.dtcenter.org/met/users/downloads/observation_data.php)
>>>>     - For 3-hourly data:
>>>> http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42.shtml
>>>>     - For 24-hourly data:
>>>>
http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.shtml
>>>>
>>>>       On the NASA site, make sure that "Accumulated Rainfall" is
>> selected,
>>>> choose your lat/lon region of interest, and choose your dates of
>> interest.
>>>>       Then click the "ASCII Output" button.
>>>>       Save the resulting ASCII data to a file locally.
>>>>
>>>> (2) Pull down the updated version of the trmm2nc.R script:
>>>>
http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
>>>>
>>>> (3) Run the data you pulled through the trmm2nc.R script.
>>>>       Rscript trmm2nc.R data.ascii data.nc
>>>>
>>>> (4) View the resulting data using either "ncview", Unidata's IDV
>> program,
>>>> or MET's plot_data_plane utility.
>>>>
>>>> Do those step work for you, or are you still experiencing
problems?
>>>>
>>>> Thanks,
>>>> John Halley Gotway
>>>> met_help at ucar.edu
>>>>
>>>>
>>>> On 09/05/2012 10:40 AM, Gisela Daniela Charó via RT wrote:
>>>>>
>>>>> Wed Sep 05 10:40:16 2012: Request 58112 was acted upon.
>>>>> Transaction: Ticket created by charogiselad at gmail.com
>>>>>           Queue: met_help
>>>>>         Subject: Question about trmm2nc.R
>>>>>           Owner: Nobody
>>>>>      Requestors: charogiselad at gmail.com
>>>>>          Status: new
>>>>>     Ticket <URL:
>> https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
>>>>>
>>>>>
>>>>> Dear met_help,
>>>>> I am working with trmm 24 hours data to compare with our WRF
results.
>>>>> I processed trmm2nc with the version included in METv3.1
>>>>> I send you the ncdump of  the nc file generated by R,where there
is no
>>>>> information about init and valid time.
>>>>>
>>>>>     dimensions:
>>>>>            lon = 49 ;
>>>>>            lat = 41 ;
>>>>> variables:
>>>>>            double lon(lon) ;
>>>>>                    lon:units = "degrees_east" ;
>>>>>                    lon:long_name = "lon" ;
>>>>>            double lat(lat) ;
>>>>>                    lat:units = "degrees_north" ;
>>>>>                    lat:long_name = "lat" ;
>>>>>            float APCP_NA(lat, lon) ;
>>>>>                    APCP_NA:units = "kg/m^2" ;
>>>>>                    APCP_NA:_FillValue = -9999.f ;
>>>>>                    APCP_NA:long_name = "Total precipitation" ;
>>>>>                    APCP_NA:name = "APCP" ;
>>>>>                    APCP_NA:level = "ANA" ;
>>>>>                    APCP_NA:grib_code = 61. ;
>>>>>                    APCP_NA:init_time = "NA" ;
>>>>>                    APCP_NA:init_time_ut = NaN ;
>>>>>                    APCP_NA:valid_time = "NA" ;
>>>>>                    APCP_NA:valid_time_ut = NaN ;
>>>>>                    APCP_NA:accum_time = "NA0000" ;
>>>>>                    APCP_NA:accum_time_sec = NaN ;
>>>>>
>>>>>
>>>>> In other hand, It is not clear the following script
instructions.In
>>>>> particular why 22.5 is substracted from the end date.
>>>>> Thanks for your help,
>>>>> Gisela
>>>>>
>>>>>
>>>>> if(acc_type == 03) {
>>>>>
>>>>>
>>>>>
>>>>>      # For 03-hour accumulations, the time stamp gives the
middle of
>> the  #
>>>>> accumulation interval.
>>>>>      # Subtract 1.5 hours from the begin timestamp to get the
init time.
>>>>>      # Add 1.5 hours to the end timestamp to get the valid time.
>>>>>
>>>>>      init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>>>> '-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
>>>>>
>>>>>      valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>>>> '-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)
>>>>>
>>>>>
>>>>>
>>>>> } else {
>>>>>
>>>>>
>>>>>
>>>>>      # The 24-hour accumulations are actually a sum of 03-hour
>>>> accumulations:
>>>>>
>>>>>      #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z
>>>>>
>>>>>      # Subtract 1.5 hours from the begin date to get the init
time.
>>>>>
>>>>>      # Add 22.5 hours to the end date to get the valid time.
>>>>>
>>>>>
>>>>>
>>>>>      init  =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>>>> '-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
>>>>>
>>>>>      valid =
as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
>>>>> '-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> # Compute the accumulation interval
>>>>>
>>>>> acc_sec =  as.double(valid - init, units="secs")
>>>>>
>>>>> acc_hr  = floor(acc_sec / 3600)
>>>>>
>>>>> acc_str = sprintf("%.2i", acc_hr)
>>>>>
>>>>
>>>>
>>>>
>>
>>
>>


------------------------------------------------
Subject: Question about trmm2nc.R
From: Gisela Daniela Charó
Time: Fri Sep 07 12:29:04 2012

Thank you very much for your help!

2012/9/6 John Halley Gotway via RT <met_help at ucar.edu>

> Gisela,
>
> Where it used to say "TRMM", it now says "Daily":
>
>     # Determine the accumlation interval
>     if(as.character(hdr[1,3]) == "Daily") {
>
> That was the source of the problem you ran into.
>
> John
>
> On 09/06/2012 09:07 AM, Gisela Daniela Charó via RT wrote:
> >
> > <URL: https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
> >
> > Hi John, I download that version on that link, but it the same as
the
> older
> > version, isn´t it?
> > Thanks!
> > Gisela
> >
> > 2012/9/6 John Halley Gotway via RT <met_help at ucar.edu>
> >
> >> Gisela,
> >>
> >> Yes, the change you describe is exactly the change I made to the
> trmm2nc.R
> >> script posted on the MET website:
> >>
http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
> >>
> >> That's why I asked you to pull down the updated version of that
script.
> >>   But I am very glad to hear that it is now working for you.
> >>
> >> Just let us know if more issues arise in your use of MET.
> >>
> >> Thanks,
> >> John
> >>
> >> On 09/06/2012 07:40 AM, Gisela Daniela Charó via RT wrote:
> >>>
> >>> <URL: https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
> >>>
> >>> Hi John,
> >>> I followed that steps,when I got the 24-hourly data ascii file
on the
> >> NASA
> >>> website , on the header of the file there was :
> >>>
> >>> Selected parameter: Daily TRMM 3B42(V7) Accumulated Rainfall
> >>> Selected area: lat=[50S,0], lon=[85W,35W]
> >>> Selected time period: (24Oct2011-25Oct2011)
> >>> Undefined/Missing Value: -9999.9
> >>> Unit: (mm)
> >>>
> >>>
> >>> When I run trmm2nc.R , I got this message:
> >>>
> >>> ERROR: Can't figure out the accumulation interval!
> >>>
> >>> So, I  changed  this part of the script, instead of TRMM I put
Daily,
> and
> >>> it works!
> >>>
> >>> # Determine the accumlation interval
> >>> if(as.character(hdr[1,3]) == "TRMM") {
> >>>     acc_type = 24
> >>> } else if(as.character(hdr[1,3]) == "3-hourly") {
> >>>     acc_type = 3
> >>> } else {
> >>>     cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
> >>>     exit(1)
> >>> }
> >>> # Determine the accumlation interval
> >>> if(as.character(hdr[1,3]) == "Daily") {
> >>>     acc_type = 24
> >>> } else if(as.character(hdr[1,3]) == "3-hourly") {
> >>>     acc_type = 3
> >>> } else {
> >>>     cat("\n\nERROR: Can\'t figure out the accumulation
interval!\n\n")
> >>>     exit(1)
> >>> }
> >>>
> >>> Thanks for your help!
> >>> Gisela
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> 2012/9/5 John Halley Gotway via RT <met_help at ucar.edu>
> >>>
> >>>> Gisela,
> >>>>
> >>>> I stepped through the process of retrieving TRMM data from the
NASA
> >>>> website and running it through the trmm2nc.R script.  But I was
unable
> >> to
> >>>> reproduce the problem you describe.  However, I did find a
> >>>> small issue in the Rscript when checking if the data is 3-
hourly or
> >>>> 24-hourly.  I've corrected that and updated the version of
trmm2nc.R
> on
> >> the
> >>>> MET website.
> >>>>
> >>>> Please try going through the following steps to see if the
issue is
> >>>> resolved:
> >>>>
> >>>> (1) Download some TRMM data in ASCII format...
> >>>>     - The MET website lists links to this data (
> >>>>
http://www.dtcenter.org/met/users/downloads/observation_data.php)
> >>>>     - For 3-hourly data:
> >>>> http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42.shtml
> >>>>     - For 24-hourly data:
> >>>>
http://disc2.nascom.nasa.gov/Giovanni/tovas/TRMM_V7.3B42_daily.shtml
> >>>>
> >>>>       On the NASA site, make sure that "Accumulated Rainfall"
is
> >> selected,
> >>>> choose your lat/lon region of interest, and choose your dates
of
> >> interest.
> >>>>       Then click the "ASCII Output" button.
> >>>>       Save the resulting ASCII data to a file locally.
> >>>>
> >>>> (2) Pull down the updated version of the trmm2nc.R script:
> >>>>
http://www.dtcenter.org/met/users/downloads/Rscripts/trmm2nc.R
> >>>>
> >>>> (3) Run the data you pulled through the trmm2nc.R script.
> >>>>       Rscript trmm2nc.R data.ascii data.nc
> >>>>
> >>>> (4) View the resulting data using either "ncview", Unidata's
IDV
> >> program,
> >>>> or MET's plot_data_plane utility.
> >>>>
> >>>> Do those step work for you, or are you still experiencing
problems?
> >>>>
> >>>> Thanks,
> >>>> John Halley Gotway
> >>>> met_help at ucar.edu
> >>>>
> >>>>
> >>>> On 09/05/2012 10:40 AM, Gisela Daniela Charó via RT wrote:
> >>>>>
> >>>>> Wed Sep 05 10:40:16 2012: Request 58112 was acted upon.
> >>>>> Transaction: Ticket created by charogiselad at gmail.com
> >>>>>           Queue: met_help
> >>>>>         Subject: Question about trmm2nc.R
> >>>>>           Owner: Nobody
> >>>>>      Requestors: charogiselad at gmail.com
> >>>>>          Status: new
> >>>>>     Ticket <URL:
> >> https://rt.rap.ucar.edu/rt/Ticket/Display.html?id=58112 >
> >>>>>
> >>>>>
> >>>>> Dear met_help,
> >>>>> I am working with trmm 24 hours data to compare with our WRF
results.
> >>>>> I processed trmm2nc with the version included in METv3.1
> >>>>> I send you the ncdump of  the nc file generated by R,where
there is
> no
> >>>>> information about init and valid time.
> >>>>>
> >>>>>     dimensions:
> >>>>>            lon = 49 ;
> >>>>>            lat = 41 ;
> >>>>> variables:
> >>>>>            double lon(lon) ;
> >>>>>                    lon:units = "degrees_east" ;
> >>>>>                    lon:long_name = "lon" ;
> >>>>>            double lat(lat) ;
> >>>>>                    lat:units = "degrees_north" ;
> >>>>>                    lat:long_name = "lat" ;
> >>>>>            float APCP_NA(lat, lon) ;
> >>>>>                    APCP_NA:units = "kg/m^2" ;
> >>>>>                    APCP_NA:_FillValue = -9999.f ;
> >>>>>                    APCP_NA:long_name = "Total precipitation" ;
> >>>>>                    APCP_NA:name = "APCP" ;
> >>>>>                    APCP_NA:level = "ANA" ;
> >>>>>                    APCP_NA:grib_code = 61. ;
> >>>>>                    APCP_NA:init_time = "NA" ;
> >>>>>                    APCP_NA:init_time_ut = NaN ;
> >>>>>                    APCP_NA:valid_time = "NA" ;
> >>>>>                    APCP_NA:valid_time_ut = NaN ;
> >>>>>                    APCP_NA:accum_time = "NA0000" ;
> >>>>>                    APCP_NA:accum_time_sec = NaN ;
> >>>>>
> >>>>>
> >>>>> In other hand, It is not clear the following script
instructions.In
> >>>>> particular why 22.5 is substracted from the end date.
> >>>>> Thanks for your help,
> >>>>> Gisela
> >>>>>
> >>>>>
> >>>>> if(acc_type == 03) {
> >>>>>
> >>>>>
> >>>>>
> >>>>>      # For 03-hour accumulations, the time stamp gives the
middle of
> >> the  #
> >>>>> accumulation interval.
> >>>>>      # Subtract 1.5 hours from the begin timestamp to get the
init
> time.
> >>>>>      # Add 1.5 hours to the end timestamp to get the valid
time.
> >>>>>
> >>>>>      init  =
> as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>>>> '-'))[1], format="(%HZ%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
> >>>>>
> >>>>>      valid =
> as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>>>> '-'))[2], format="%HZ%d%b%Y)", tz="GMT") + 1.5*sec_per_hr)
> >>>>>
> >>>>>
> >>>>>
> >>>>> } else {
> >>>>>
> >>>>>
> >>>>>
> >>>>>      # The 24-hour accumulations are actually a sum of 03-hour
> >>>> accumulations:
> >>>>>
> >>>>>      #   00Z, 03Z, 06Z, 12Z, 15Z, 18Z, and 21Z
> >>>>>
> >>>>>      # Subtract 1.5 hours from the begin date to get the init
time.
> >>>>>
> >>>>>      # Add 22.5 hours to the end date to get the valid time.
> >>>>>
> >>>>>
> >>>>>
> >>>>>      init  =
> as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>>>> '-'))[1],  format="(%d%b%Y", tz="GMT") - 1.5*sec_per_hr)
> >>>>>
> >>>>>      valid =
> as.POSIXct(strptime(unlist(strsplit(as.character(hdr[3,4]),
> >>>>> '-'))[2], format="%d%b%Y)", tz="GMT") + 22.5*sec_per_hr)
> >>>>>
> >>>>> }
> >>>>>
> >>>>>
> >>>>>
> >>>>> # Compute the accumulation interval
> >>>>>
> >>>>> acc_sec =  as.double(valid - init, units="secs")
> >>>>>
> >>>>> acc_hr  = floor(acc_sec / 3600)
> >>>>>
> >>>>> acc_str = sprintf("%.2i", acc_hr)
> >>>>>
> >>>>
> >>>>
> >>>>
> >>
> >>
> >>
>
>
>

------------------------------------------------


More information about the Met_help mailing list