コード例 #1
0
  
def OutputJsonFiles(outputPath, valueType):
    for municipality in stationsByMunicipality:
        municipalityPath = os.path.join(outputPath, municipality)
        EnsurePathExists(municipalityPath)

        stations = stationsByMunicipality[municipality]
        for stationName in stations:
            stationPath = os.path.join(municipalityPath, stationName)
            EnsurePathExists(stationPath)

            outputFilePath = os.path.join(stationPath, f'{valueType}.json')
            print(stationPath)
            with open(outputFilePath, mode="w", encoding="utf-8") as stationFile:
                json.dump(stations[stationName], stationFile)

argumentParser = argparse.ArgumentParser()
argumentParser.add_argument("--input", "-i", help="provide the input folder")
argumentParser.add_argument("--output", "-o", help="provide the output folder")
argumentParser.add_argument("--municipalities", "-m", help="provide the output folder")
argumentParser.add_argument("--type", "-t", help="'hourly', 'daily' or 'yearly'")

args = argumentParser.parse_args()

inputPath = GetPathFromArgument("input", args.input)
outputPath = GetPathFromArgument("output", args.output, False, True)
municipalitiesPath = GetPathFromArgument("municipalities", args.municipalities, True)
valueType = GetValueTypeFromArgument(args.type)

InitializeMunicipalities(municipalitiesPath)
AggregateValuesByStation(inputPath, outputPath, valueType)
コード例 #2
0
        response = requests.get(url)
        response.raise_for_status()
        contents = response.text

        with open(filePath, mode="w", encoding="utf-8") as file:
            file.write(contents)


argumentParser = argparse.ArgumentParser()
argumentParser.add_argument("--outputpath",
                            "-o",
                            help="provide the output folder.")
argumentParser.add_argument(
    "--startdate",
    "-s",
    help="provide the output folder in the format %Y-%m-%d")
argumentParser.add_argument(
    "--hourly",
    "-t",
    action='store_true',
    help=
    "a flag indicating that the hourly measurements should be retrieved instead of the daily."
)

args = argumentParser.parse_args()

startDate = GetStartDate(args.startdate)
path = GetPathFromArgument("path", args.outputpath, False, True)

GetMeasurements(startDate, path, args.hourly)
コード例 #3
0
    return value["qualityControlled"] == True


def GetTimestepFraction(value, componentName):
    timestep = value['timestep']

    if timestep > 3600:
        raise Exception(f"Timestep larger than on hour: {timestep}")

    if timestep != 3600:
        global PreviousWeirdComponent
        if componentName != PreviousWeirdComponent:
            PreviousWeirdComponent = componentName
            print(f"---- {componentName} ---- {timestep}")

    return timestep / 3600


argumentParser = argparse.ArgumentParser()
argumentParser.add_argument(
    "--path", "-p", help="provide the folder containing all station folders")
argumentParser.add_argument("--outputfile",
                            "-o",
                            help="provide the name of the output files")

args = argumentParser.parse_args()

path = GetPathFromArgument("path", args.path)
outputFileName = args.outputfile

AggregateByMean(path, outputFileName)
コード例 #4
0

def OutputStation(stationPath, station, outputFileName):
    outputPath = os.path.join(stationPath, outputFileName)
    with open(outputPath, mode="w", encoding="utf-8") as outputFile:
        json.dump(station, outputFile)


argumentParser = argparse.ArgumentParser()
argumentParser.add_argument("--settings",
                            "-s",
                            help="provide the output folder")
argumentParser.add_argument(
    "--path", "-p", help="provide the folder containing all station folders")
argumentParser.add_argument("--inputfile",
                            "-i",
                            help="provide the name of the yearly input files")
argumentParser.add_argument("--outputfile",
                            "-o",
                            help="provide the name of the yearly output files")
argumentParser.add_argument("--type", "-t", help="'hourly', 'daily'")

args = argumentParser.parse_args()

settingsPath = GetPathFromArgument("thresholds", args.settings)
path = GetPathFromArgument("path", args.path)
inputFileName = args.inputfile
outputFileName = args.outputfile
valueType = GetValueTypeFromArgument(args.type)

AddThresholdValues(path, valueType, inputFileName, outputFileName)