Esempio n. 1
0
 def setUp(self):
     self.projectDir = tempfile.mkdtemp()
     self.testMetadataPath = os.path.join(self.projectDir, GenericMetadata.METADATA_FILENAME)
     if os.path.exists(self.testMetadataPath):
         os.unlink(self.testMetadataPath)
     lockFilePath = os.path.join(self.projectDir, GenericMetadata.METADATA_LOCKFILE)
     if os.path.exists(lockFilePath):
         os.unlink(lockFilePath)
     self.context = Context(projectDir=self.projectDir)
Esempio n. 2
0
 def __init__(self, projectDir, configFile=None, outfp=sys.stdout):
     """ Construct a EcohydroLib abstract command.  Concrete commands
         must call this super class method in their constructor.
     
     Arguments:
     projectDir -- string    The path to the project directory
     configFile -- string    The path to an EcohydroLib configuration file
     outfp -- file-like object    Where output should be written to
     
     """
     self.context = Context(projectDir, configFile)
     self.outfp = outfp
Esempio n. 3
0
                    choices=CODECS,
                    help="Video codec to use. Default: %s" % (DEFAULT_CODEC, ))
parser.add_argument(
    '--rescale',
    required=False,
    type=float,
    help=
    'Rescale raster values of 0 to args.resample to 0 to 255 in output images.'
)
args = parser.parse_args()

configFile = None
if args.configfile:
    configFile = args.configfile

context = Context(args.projectDir, configFile)

ffmpegPath = context.config.get('RHESSYS', 'PATH_OF_FFMPEG')

# Check for necessary information in metadata
metadata = RHESSysMetadata.readRHESSysEntries(context)
if not 'grass_dbase' in metadata:
    sys.exit(
        "Metadata in project directory %s does not contain a GRASS Dbase" %
        (context.projectDir, ))
if not 'grass_location' in metadata:
    sys.exit(
        "Metadata in project directory %s does not contain a GRASS location" %
        (context.projectDir, ))
if not 'grass_mapset' in metadata:
    sys.exit(
Esempio n. 4
0
parser = argparse.ArgumentParser(
    description=
    'Dump point climate station information from EcohydroLib metadata to standard output'
)
parser.add_argument('-p',
                    '--projectDir',
                    dest='projectDir',
                    required=True,
                    help='The directory from which metadata should be read')
parser.add_argument('-s',
                    '--separator',
                    dest='separator',
                    required=False,
                    default=',',
                    help='Field separator for output')
args = parser.parse_args()

context = Context(args.projectDir, None)

s = args.separator

sys.stderr.write("Getting stations from metadata... ")
stations = GenericMetadata.readClimatePointStations(context)
sys.stderr.write("done\n")

for station in stations:
    output = station.id.upper() + s + str(station.latitude) + s + str(
        station.longitude) + s + str(
            station.elevation) + s + station.name + os.linesep
    sys.stdout.write(output)
Esempio n. 5
0
 def setUp(self):
     self.projectDir = tempfile.mkdtemp()
     self.context = Context(projectDir=self.projectDir)