This is kind of specific to the algorithm I am using. But basically, I have an algorithm that runs using the following command:
w2cropconv -i /mnt/data/SHAVE_cubes/20120329/multi0/code_index.xml -I "Heightof0C" -o /mnt/data/SHAVE_cubes/20120329/multi0/.. -t "38.4 -97.85 21" -b "37.8 -97.15 1" -s "0.005 0.005 1" -R I run it with popen() using the following command:
p = subprocess.Popen( [ "w2cropconv", "-i", path, "-I", "HeightofOC", "-o", output_directory, "-t", NWloc, "-b", SEloc, "-s", "0.005 0.005 1", "-R", ] ) While the popen() command runs correctly, it does not actually output anything. In the first case, the algorithm outputs to the /multi0/ directory. The popep() function does not write to that directory, even though it really should. It is not a bug in my coding, I am convinced that it is something specific to popep() that I do not know.
I know that the input and output directories are the same because when I execute either, I get the following:
key [i], val [/mnt/data/SHAVE_cubes/20120329/multi0/code_index.xml] key [I], val [HeightofOC] key [o], val [/mnt/data/SHAVE_cubes/20120329/Heightof0C] key [t], val [38.4 -97.85 21] key [b], val [37.8 -97.15 1] key [s], val [0.01 0.01 1] key [R], val [true] When they diverge, the correct process yields this output:
(../util/code_W2Unit.cc:66 getUtUnit) Initializing UDUNITS, Version 2 or greater... (../util/code_W2Unit.cc:82 getUtUnit) Set UDUNITS2_XML_PATH=/usr/local/WDSS2/WDSS2/w2/w2config/misc/udunits2.xml (code_LatLonConverter.cc:208 processInputField) Converting LatLonGrid: Heightof0C at 20120329-210000 location (lat=[58.366001 deg],lon=[-139.856 deg],h=[0 km]) and creating 1 output grids (code_DataRemapper.cc:138 getLookup) DataRemapper: creating lookup for LatLonGrid NWcorner: Loc: 58.4 -139.9 dim: [225 x 301] latres: [0.188] lonres: [0.275] to LatLonGrid NWcorner: Loc: 38.4 -97.8 dim: [120 x 140] latres: [0.005] lonres: [0.005] (code_DataRemapper.cc:140 getLookup) There are now 1 remapping lookup tables stored. (code_NetcdfDataEncoder.cc:122 applySettings) Using FINAL SPARSEGRID threshold of {-1} based on settings in w2config/misc/dataformat . Please excuse me if I do not answer right away, I am having a headache.
pathandoutput_directoryare exactly correct? Maybe trysubprocess.check_call();Popenitself won't raise an exception if the command exits with a nonzero status code.Popenwill return an object representing the process you would have to wait to exit;check_call()does that for you.)