[Thread Prev][Thread Next][Index]

Re: [ferret_users] Pyferret file naming



Hi Roger,

You need to construct the complete command line in python.  The Ferret command processing within PyFerret does not know about python variables.  So something like:

    import os
    import pyferret

    pyferret.start(quiet=True)

    input_dir = ....
    file_name = ....

    ferret_cmd = 'use "' + os.path.join(input_dir, file_name) + '"'
    pyferret.run(ferret_cmd)

(I am putting the filename in double quotes and using os.path.join just to be safe.)

Karl


On Fri, Aug 4, 2017 at 5:48 PM, Roger Bodman <rwbodman@xxxxxxxxx> wrote:
Hi,


I am trying out pyferret.  I can construct a file name in python, having set the appropriate string variables, then:


>>> input_file = input_dir + file_name


and start pyferret:


>>> pyferret.start(quiet=3DTrue)

True?


but I can't get the syntax correct to use the file


>>> (errval, errmsg) =3D pyferret.run('use input_file')

 **TMAP ERR: non-existent or not on line

             Searched $FER_DESCR and $FER_DATA for input_file(.nc ,.cdf,.des)


I want to use the full file path/fiilename, equivalent to


use "/um-results/ESM1_HI-C2C-10E_results/HI-C2C-10E_ohc_cube19510630.nc"


which works fine in the usual way, and not have to worry about moving files=
 to $FER_DATA


Thanks,


Roger





--
Karl M. Smith, Ph.D.
JISAO Univ. Wash. and PMEL NOAA
"The contents of this message are mine personally and do
not necessarily reflect any position of the Government
or the National Oceanic and Atmospheric Administration."

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

Privacy Policy | Disclaimer | Accessibility Statement