[Thread Prev][Thread Next][Index]

Re: [ferret_users] Writing output to txt file



Hi Billy,

As a matter of fact, this very feature was added to Ferret in May
2011, in response to requests from us at GFDL.  It's called SET
REDIRECT, and it works like this:

  NOAA/PMEL TMAP
  FERRET v6.725
  Linux 2.6.18-274.12.1.el5 64-bit - 04/10/12
  7-Aug-14 18:03

yes? use coads_climatology
yes? set redirect/tee/journal
yes? show data
     currently SET data sets:
    1> /home/atw/ferret/exe/x86_64/rhel6/ferret-6.72/fer_dsets/data/coads_climatology.cdf
 (default)
 name     title                             I         J         K         L
 SST      SEA SURFACE TEMPERATURE          1:180     1:90      ...       1:12
 AIRT     AIR TEMPERATURE                  1:180     1:90      ...       1:12
 SPEH     SPECIFIC HUMIDITY                1:180     1:90      ...       1:12
 WSPD     WIND SPEED                       1:180     1:90      ...       1:12
 UWND     ZONAL WIND                       1:180     1:90      ...       1:12
 VWND     MERIDIONAL WIND                  1:180     1:90      ...       1:12
 SLP      SEA LEVEL PRESSURE               1:180     1:90      ...       1:12

yes? spawn cat ferret.jnl
 ! NOAA/PMEL TMAP
 ! FERRET v6.725
 ! Linux 2.6.18-274.12.1.el5 64-bit - 04/10/12
 !  7-Aug-14 18:03

use coads_climatology
set redirect/tee/journal
sho dat
!     currently SET data sets:
!    1> /home/atw/ferret/exe/x86_64/rhel6/ferret-6.72/fer_dsets/data/coads_climatology.cdf
 (default)
! name     title                             I         J         K         L
! SST      SEA SURFACE TEMPERATURE          1:180     1:90      ...       1:12
! AIRT     AIR TEMPERATURE                  1:180     1:90      ...       1:12
! SPEH     SPECIFIC HUMIDITY                1:180     1:90      ...       1:12
! WSPD     WIND SPEED                       1:180     1:90      ...       1:12
! UWND     ZONAL WIND                       1:180     1:90      ...       1:12
! VWND     MERIDIONAL WIND                  1:180     1:90      ...       1:12
! SLP      SEA LEVEL PRESSURE               1:180     1:90      ...       1:12
!
sp cat ferret.jnl
yes? cancel redirect


Alternatively you can redirect to an arbitrary text file, so you can
grep and sed and awk to your heart's content using the SPAWN command
or SPAWN() function.  Full documentation of SET REDIRECT is here:

http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/SET#_VPINDEXENTRY_SET_REDIRECT

Andrew

---
Dr. Andrew T. Wittenberg
Physical Scientist (NOAA Federal)
Climate Change, Variability, and Prediction Group
NOAA/Geophysical Fluid Dynamics Laboratory
201 Forrestal Road
Princeton, NJ 08540-6649
USA
http://www.gfdl.noaa.gov/~atw


On Thu, Aug 7, 2014 at 4:21 PM, William S. Kessler
<william.s.kessler@xxxxxxxx> wrote:
> Beyond this, it would be useful to be able to direct certain output to the jnl file as additional documentation.
>
> A cheap workaround is to give the command, then simply copy/paste the resulting text back into Ferret. Ferret will complain on each line (making an ugly screen), but these complaints do not appear in the jnl file. You get quite readable output.
>
> I often search the jnl files for, say, occurrences of "use" so I can tell which files were used to made a certain plot. But if I've brought data in via a script (as usual), that might not tell me what I want to know, or it might require additional searching through perhaps several scripts. I often wish to be able to easily send the output of SHO DAT/BRIEF to the jnl file, for instance, after making a plot. There are lots of other examples. This ability would be a great enhancement.
>
> Billy K
>
> On Aug 7, 2014, at 10:15 , Ansley Manke wrote:
>
>> Hi,
>> STAT is a command that displays its result to standard output. It's not a function, so "LIST STAT varname" is not valid syntax.
>>
>> You can get the information from STAT into variables by using the set of symbols that are automatically defined when you issue the STAT command.
>> yes? stat sst
>>
>>              SEA SURFACE TEMPERATURE
>>              LONGITUDE: 20E to 20E(380)
>>              LATITUDE: 90S to 90N
>>              Z:  N/A
>>              TIME: 01-JAN 00:45 to 31-DEC 06:34
>>              E:  N/A
>>              F:  N/A
>>              DATA SET: /home/users/tmap/ferret/linux/fer_dsets/data/coads_climatology.cdf
>>
>>  Total # of data points: 194400 (180*90*1*12*1*1)
>>  # flagged as bad  data: 89622
>>  Minimum value: -2.6
>>  Maximum value: 33.15
>>  Mean    value: 18.095 (unweighted average)
>>  Standard deviation: 9.4023
>>
>> yes? sh sym stat*
>> STAT_MIN = "-2.6"
>> STAT_MAX = "33.15"
>> STAT_MEAN = "18.095"
>> STAT_STD = "9.4023"
>> STAT_NGOOD = "104778"
>> STAT_NBAD = "89622"
>> so you could write
>>  let varmean = ($stat_mean)
>>  let varstd = ($stat_var)
>>  ...
>> and then list those to your file.  It would be best to add /TITLE= and /UNITS=  to the LET commands so the information is documented.
>>
>> There are also functions and transformations that return the same information; the @AVE, @VAR, @NGD, @NBD, @MIN and @MAX transformations could be used to set up variables containing that information, or this function to return both the min and max.
>>
>> yes? show func minmax
>>
>>
>>
>> On 8/6/2014 11:06 PM, Nitin Patil wrote:
>>> Dear All,
>>>
>>> My script is as follows:
>>>
>>> let gp1=Optical_Depth_Land_And_Ocean_Mean[d=1,x=73:81@ave,y=30:33@ave,k=1:122]
>>> let gp2=Optical_Depth_Land_And_Ocean_Mean[d=1,x=73:85@ave,y=25:29@ave,k=1:122]
>>> let mean=(gp1+gp2)/2
>>> stat mean
>>> list/file=GP2002.txt stat mean !!! NOT WORKING
>>>
>>> I want to write the stat mean output in a txt file, any idea.
>>>
>>>
>>> --
>>> Regards,
>>> Nitin Patil
>>
>
>



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

Privacy Policy | Disclaimer | Accessibility Statement