[Wrf-users] Extracting time series at a given geographical position

HEDDE Thierry 137147 thierry.hedde at cea.fr
Mon May 30 08:09:01 MDT 2016


Hi peter,

You may encapsulate the read_wrf_nc call in a shell or perl script in a loop, so you’ll be able to call read_wrf_nc at the locations you want using shell or perl arguments or even reading a list of the location you want. I have no simple examples of this, just go and see perl tutorials for this for example.

I join an example of a perl call to getTimeSerie function and the function itself in perl.
You may get some hints from that.
Of course it’s not usable like that and if you don’t know perl langage you should follow some tutos before.

Cheers
Thierry

Example of making a list of variables to read for a given location and call reading the function
  # ----------------------------------------------
  $list_var="U10 V10 T2 Q2 RAINNC PSFC SNOWH TSK";            # V3.10 2016-01-14 add TSK reading (surface T)
  # ----------------------------------------------
  $level = 1;
  $fileout="${dirout_arg}/${locname}${infixe}_d${domain}_${latlonhgt}_ground.dat";
  $tmpfile = &getTimeSerie($WRFOUT_ptr, $latitude, $longitude, $list_var, $level, $fileout);


The timeserie reading function calling read_wrf_nc
#  Extaction d'une serie temporelle quelconque d'un wrfout

sub getTimeSerie{
  push(@subindent,$indent);

  my ($WRFOUT_ptr, $latitude, $longitude, $vars, $level, $fileout) = @_;
  my $subname = (caller(0))[3];
  ($debug) && print  "@subindent>$subname>vars=$vars\n";

  #On détruit le vieux fichier tsfileout sinon read_wrf_nc ajoute les extractions à la fin du fichier
  my $tsfileout="TIME_SERIES.out"; # compulsory name from read_wrf_nc prm
  (-e $tsfileout) && (unlink($tsfileout) || die "$pf>@subindent>$subname>ERROR: Cant erase file:$tsfileout\n");

  #arguments
  #     my $filein = "";    # Fichier wrfout à lire
  #     my $latitude  = 0;  # Latitude du point à extraire
  #     my $longitude = 0;  # Longiitude du point à extraire
  #     my $vars      = ""; # Liste des variables à extraire
  #     my $level     = ""; # Indice du niveau vertical d'extraction
  #     my $fileout   = ""; # Fichier de sortie


  my $tmpfile=$fileout.".tmp";

  foreach my $filein(@$WRFOUT_ptr) {
    ( -e $filein) || die "$pf>@subindent>$subname>ERROR le fichier wrfout...:$filein est introuvable\n";
    print "$pf>@subindent>$subname>Treat $filein.\n";
    # Lecture/ecriture des séries depuis le wrfout
    if ($level) {              # One level is aked for
      @args = ("$READ_WRF_NC $filein -rot -ts ll $latitude $longitude $vars -lev $level 2> read_wrf_nc.err");
    } else {                      # all levels
      @args = ("$READ_WRF_NC $filein -rot -ts ll $latitude $longitude $vars 2> read_wrf_nc.err");
   }

    print  "$pf>@subindent>$subname>@args\n";
    system(@args) == 0 or die "$pf>@subindent>$subname>ERROR: Can't execute system command @args\n";
  } # foreach my $filein(

  if (-e "$tsfileout" ) {
    ($debug) && print  "mv $tsfileout $tmpfile\n";
    `mv $tsfileout $tmpfile`;
  } else {
    die "$pf>@subindent>$subname>ERREUR: Le fichier $tsfileout n'a pas été créé.";
  }

  pop(@subindent);
  return($tmpfile);
}
#

De : Peter Tuju [mailto:peterenos at ymail.com]
Envoyé : lundi 30 mai 2016 15:53
À : wrf-users at ucar.edu; HEDDE Thierry 137147
Objet : Re: Extracting time series at a given geographical position

Dear Thierry,

I was succeeded to compile the read_wrf_nc.f and to extract T2 using the code "./read_wrf_nc wrfout_d02_2015-03-01 -w T2" which gives me the ascii file T2.out at every grid point, but I want to extract T2 at different specific locations say lat1, lat2, etc and lon1, lon2, etc. So, how can I do to solve this??.



Also I, tried to use the ncl scrips you sent to me but it just gives me the ts output  in graphic format but I want to have in ascii format say .csv or .txt.


Please guide me once more again!

_____________
Peter  E. Tuju
Dar es Salaam
T A N Z A N I A
----------------------

On Friday, May 27, 2016 7:21 AM, Peter Tuju <peterenos at ymail.com<mailto:peterenos at ymail.com>> wrote:


_____________
Peter  E. Tuju
Dar es Salaam
T A N Z A N I A
----------------------

On Thursday, May 26, 2016 12:53 PM, HEDDE Thierry 137147 <thierry.hedde at cea.fr<mailto:thierry.hedde at cea.fr>> wrote:

Hi peter,

To do this job you may use this tool :
http://www2.mmm.ucar.edu/wrf/src/read_wrf_nc.f
it's easy to use. I don't use NCL for extracting this kind of variables which are directly available from the wrfout file.

But of course you may use one of the script given on NCL site as the one I joined which I used some time ago
Or use the scripts given here :
http://www2.mmm.ucar.edu/wrf/OnLineTutorial/Graphics/NCL/Examples/SPECIAL/meteograms.htm

Have fun!
Cheers
Thierry

-----Message d'origine-----
De : wrf-users-bounces at ucar.edu<mailto:wrf-users-bounces at ucar.edu> [mailto:wrf-users-bounces at ucar.edu<mailto:wrf-users-bounces at ucar.edu>] De la part de wrf-users-request at ucar.edu<mailto:wrf-users-request at ucar.edu>
Envoyé : mercredi 25 mai 2016 20:00
À : wrf-users at ucar.edu<mailto:wrf-users at ucar.edu>
Objet : Wrf-users Digest, Vol 141, Issue 15

Send Wrf-users mailing list submissions to
    wrf-users at ucar.edu<mailto:wrf-users at ucar.edu>

To subscribe or unsubscribe via the World Wide Web, visit
    http://mailman.ucar.edu/mailman/listinfo/wrf-users
or, via email, send a message with subject or body 'help' to
    wrf-users-request at ucar.edu<mailto:wrf-users-request at ucar.edu>

You can reach the person managing the list at
    wrf-users-owner at ucar.edu<mailto:wrf-users-owner at ucar.edu>

When replying, please edit your Subject line so it is more specific than "Re: Contents of Wrf-users digest..."


Today's Topics:

  1. Re: NCL Script to extract ASCII data from wrfout (Peter Tuju)


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

Message: 1
Date: Wed, 25 May 2016 04:37:40 +0000 (UTC)
From: Peter Tuju <peterenos at ymail.com<mailto:peterenos at ymail.com>>
Subject: Re: [Wrf-users] NCL Script to extract ASCII data from wrfout
To: "wrf-users-request at ucar.edu<mailto:wrf-users-request at ucar.edu>" <wrf-users-request at ucar.edu<mailto:wrf-users-request at ucar.edu>>,
    wrf-users at ucar.edu<mailto:wrf-users at ucar.edu>
Message-ID:
    <316471855.208077.1464151060245.JavaMail.yahoo at mail.yahoo.com<mailto:316471855.208077.1464151060245.JavaMail.yahoo at mail.yahoo.com>>
Content-Type: text/plain; charset="utf-8"

blockquote, div.yahoo_quoted { margin-left: 0 !important; border-left:1px #715FFA solid !important; padding-left:1ex !important; background-color:white !important; } Dear wrf users,?Please help me with the ncl script to extract ascii parameters say RAINC, RAINNC, T2, RH, U_10m, V_10m etc from wrfout.nc at a specific point latitude and longitude ?and save the output in a . csv or . txt format. Please help, I'm totally bored now!!!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/wrf-users/attachments/20160525/3c78d6bc/attachment-0001.html

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

_______________________________________________
Wrf-users mailing list
Wrf-users at ucar.edu<mailto:Wrf-users at ucar.edu>
http://mailman.ucar.edu/mailman/listinfo/wrf-users


End of Wrf-users Digest, Vol 141, Issue 15
******************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/wrf-users/attachments/20160530/ac95d31f/attachment-0001.html 


More information about the Wrf-users mailing list