예제 #1
0
    def msg_mpe_1dcum(input_file, output_file):
        #
        output_file = functions.list_to_element(output_file)
        functions.check_output_dir(os.path.dirname(output_file))

        tmpdir = tempfile.mkdtemp(prefix=__name__,
                                  suffix='',
                                  dir=es_constants.base_tmp_dir)

        tmp_output_file = tmpdir + os.path.sep + os.path.basename(output_file)
        # Divide by 10 to pass from 0.01 to 0.1 as scale factor for 1d cum
        factor = 0.1
        args = {
            "input_file": input_file,
            "output_file": tmp_output_file,
            "output_format": 'GTIFF',
            "options": "compress=lzw",
            "scale_factor": factor,
            "input_nodata": -32768
        }

        raster_image_math.do_cumulate(**args)

        reproject_output(tmp_output_file, native_mapset, target_mapset)

        # Copy the non-reprojected file for validation, only in test_mode
        if test_mode:
            msg_proj_dir = es_constants.processing_dir + functions.set_path_sub_directory(
                prod, '1dcum', 'Derived', version, native_mapset)
            functions.check_output_dir(msg_proj_dir)
            shutil.copy(tmp_output_file, msg_proj_dir + os.path.sep)

        # Copy the non-reprojected file for validation, only in test_mode
        shutil.rmtree(tmpdir)
예제 #2
0
    def lsasaf_lst_10dmin(input_file, output_file):

        output_file = functions.list_to_element(output_file)
        # Get the number of days of that dekad
        basename = os.path.basename(output_file)
        mydate = functions.get_date_from_path_filename(basename)
        functions.check_output_dir(os.path.dirname(output_file))

        tmpdir = tempfile.mkdtemp(prefix=__name__,
                                  suffix='',
                                  dir=es_constants.base_tmp_dir)

        tmp_output_file = tmpdir + os.path.sep + os.path.basename(output_file)

        args = {
            "input_file": input_file,
            "output_file": tmp_output_file,
            "output_format": 'GTIFF',
            "options": "compress=lzw",
            "input_nodata": -32768
        }

        raster_image_math.do_min_image(**args)

        reproject_output(tmp_output_file, native_mapset, target_mapset)

        shutil.rmtree(tmpdir)

        # Do also the house-keeping, by deleting the files older than 6 months
        number_months_keep = 6
        remove_old_files(prod, '10d15min', version, native_mapset, 'Ingest',
                         number_months_keep)
    def lsasaf_etp_10dcum(input_file, output_file):

        output_file = functions.list_to_element(output_file)
        # Get the number of days of that dekad
        basename=os.path.basename(output_file)
        mydate=functions.get_date_from_path_filename(basename)
        nbr_days_dekad = functions.day_per_dekad(mydate)
        # Compute the correcting factor: we sum-up all 48 30min cycles and:
        # Divide by 2 (mm/h -> mm)
        # Multiply by number of days
        # Divide by 100, so that the scale factor changes from 0.0001 (30min) to 0.01
        factor = float(nbr_days_dekad)*0.005
        functions.check_output_dir(os.path.dirname(output_file))

        tmpdir = tempfile.mkdtemp(prefix=__name__, suffix='',dir=es_constants.base_tmp_dir)

        tmp_output_file = tmpdir+os.path.sep+os.path.basename(output_file)

        args = {"input_file": input_file, "output_file": tmp_output_file, "output_format": 'GTIFF',
                "options": "compress=lzw", "scale_factor": factor, "input_nodata":-32768}

        # See ES2-416: we accept at least 40 files out of the expect 48
        if len(input_file) >= 40:

            raster_image_math.do_cumulate(**args)

            reproject_output(tmp_output_file, native_mapset, target_mapset)

            # Do also the house-keeping, by deleting the files older than 6 months
            number_months_keep = 6
            remove_old_files(prod, "10d30min-et", version, native_mapset, 'Derived', number_months_keep)

        # Remove tmp dir (moved out of if-clause - 21.11.19)
        shutil.rmtree(tmpdir)
    def lsasaf_lst_1dmax(input_file, output_file):
#
        output_file = functions.list_to_element(output_file)
        functions.check_output_dir(os.path.dirname(output_file))

        tmpdir = tempfile.mkdtemp(prefix=__name__, suffix='',dir=es_constants.base_tmp_dir)

        tmp_output_file = tmpdir+os.path.sep+os.path.basename(output_file)

        args = {"input_file": input_file, "output_file": tmp_output_file, "output_format": 'GTIFF',
                "options": "compress=lzw", "input_nodata":-32768}

        raster_image_math.do_max_image(**args)

        reproject_output(tmp_output_file, native_mapset, target_mapset)

        shutil.rmtree(tmpdir)