Exemple #1
0
def main():
    paths.build('F:')

    startday = datetime(2013, 12, 17, 0)
    endday = datetime(2013, 12, 31, 0)
    finalyear = 2013

    base_dir = paths.ndvi_individ
    output = paths.ndvi_spline

    year = '2000'
    ref_map = os.path.join(base_dir, year, 'NDVI2000_01_01.tif')
    _, _, _, _, lon, lat, linke, prj, fill_val = read_map(ref_map, 'Gtiff')

    srs = osr.SpatialReference(prj)
    sr_wkt = srs.ExportToWkt()

    for day in rrule.rrule(rrule.DAILY, dtstart=startday, until=endday):
        nr = day.strftime('%j')
        year = day.strftime('%Y')

        # ndvi_daily = time_interpolation(day, lat, lon, finalyear)
        ndvi_daily = time_interpolation(base_dir, day, finalyear)

        # Write daily values to new daily rasters
        daily_doy = 'ndvi{}_{}.tif'.format(year, nr)
        outpath = os.path.join(output, year)

        if not os.path.exists(outpath):
            os.makedirs(outpath)

        outname = os.path.join(outpath, daily_doy)
        write_map(outname, 'Gtiff', lon, lat, ndvi_daily, sr_wkt, fill_val)
def main():
    paths.build('F:')

    startday = datetime(2013, 12, 17, 0)
    endday = datetime(2013, 12, 31, 0)
    finalyear = 2013

    base_dir = paths.ndvi_individ
    output = paths.ndvi_spline

    year = '2000'
    ref_map = os.path.join(base_dir, year, 'NDVI2000_01_01.tif')
    _, _, _, _, lon, lat, linke, prj, fill_val = read_map(ref_map, 'Gtiff')

    srs = osr.SpatialReference(prj)
    sr_wkt = srs.ExportToWkt()

    for day in rrule.rrule(rrule.DAILY, dtstart=startday, until=endday):
        nr = day.strftime('%j')
        year = day.strftime('%Y')

        # ndvi_daily = time_interpolation(day, lat, lon, finalyear)
        ndvi_daily = time_interpolation(base_dir, day, finalyear)

        # Write daily values to new daily rasters
        daily_doy = 'ndvi{}_{}.tif'.format(year, nr)
        outpath = os.path.join(output, year)

        if not os.path.exists(outpath):
            os.makedirs(outpath)

        outname = os.path.join(outpath, daily_doy)
        write_map(outname, 'Gtiff', lon, lat, ndvi_daily, sr_wkt, fill_val)
Exemple #3
0
def run():
    paths.build('F:')

    penman_example = 'PM_NM_2000_001.tif'
    map_for_reference = os.path.join(paths.penman, '2000', penman_example)
    _, _, _, _, x, y, _, prj, fill_val = read_map(map_for_reference, 'Gtiff')

    start = datetime.datetime(2000, 1, 1, 0)
    end = datetime.datetime(2001, 12, 31, 0)

    fill_val = -999.

    for day in rrule.rrule(rrule.DAILY, dtstart=start, until=end):
        year = day.strftime('%Y')
        month = day.strftime('%m')
        day_mth = day.strftime('%d')

        # yearstr = str(year)
        # output = os.path.join(output_dir, new_dir, year)
        # print(output_dir)

        ndvi = get_kcb(paths.ndvi_std_all, day)

        # kcb = remake_array(mask_path, kcb)
        ndvi[ndvi == fill_val] = 0
        # print(ndvi, ndvi.shape)

        new_ndvi = 'NDVI{}_{}_{}.tif'.format(year, month, day_mth)

        output_dir = os.path.join(paths.etrm_input_root, 'NDVI_individ',
                                  str(year))
        ndvi_out = os.path.join(output_dir, new_ndvi)

        if not os.path.isdir(output_dir):
            os.makedirs(output_dir)

        print(('Saving New NDVI file as {}'.format(ndvi_out)))
        write_map(ndvi_out, 'Gtiff', x, y, ndvi, prj, fill_val)
Exemple #4
0
def run():
    paths.build('F:')

    penman_example = 'PM_NM_2000_001.tif'
    map_for_reference = os.path.join(paths.penman, '2000', penman_example)
    _, _, _, _, x, y, _, prj, fill_val = read_map(map_for_reference, 'Gtiff')

    start = datetime.datetime(2000, 1, 1, 0)
    end = datetime.datetime(2001, 12, 31, 0)

    fill_val = -999.

    for day in rrule.rrule(rrule.DAILY, dtstart=start, until=end):
        year = day.strftime('%Y')
        month = day.strftime('%m')
        day_mth = day.strftime('%d')

        # yearstr = str(year)
        # output = os.path.join(output_dir, new_dir, year)
        # print(output_dir)

        ndvi = get_kcb(paths.ndvi_std_all, day)

        # kcb = remake_array(mask_path, kcb)
        ndvi[ndvi == fill_val] = 0
        # print(ndvi, ndvi.shape)

        new_ndvi = 'NDVI{}_{}_{}.tif'.format(year, month, day_mth)

        output_dir = os.path.join(paths.etrm_input_root, 'NDVI_individ', str(year))
        ndvi_out = os.path.join(output_dir, new_ndvi)

        if not os.path.isdir(output_dir):
            os.makedirs(output_dir)

        print('Saving New NDVI file as {}'.format(ndvi_out))
        write_map(ndvi_out, 'Gtiff', x, y, ndvi, prj, fill_val)