<commit_before>import glob
import pandas as pd
import datetime
import subprocess
import os
import sys
sys.path.append('../')
import constants_and_names as cn
import universal_util as uu


def merge_warp_forest_extent_tiles(tile_id, raw_forest_extent_inputs, out_pattern, dt):

    # Start time
    start = datetime.datetime.now()

    tile = '{0}_{1}.tif'.format(tile_id, out_pattern)

    print "Getting extent of", tile
    xmin, ymin, xmax, ymax = uu.coords(tile_id)

    cmd = ['gdal_merge.py', '-o', tile,
           '-co', 'COMPRESS=LZW', '-a_nodata', '0', '-n', '0', '-ot', dt,
           '-ps', cn.Hansen_res, cn.Hansen_res, '-ul_lr', xmax, ymax, xmin, ymin,
           raw_forest_extent_inputs[0], raw_forest_extent_inputs[1], raw_forest_extent_inputs[2],
           raw_forest_extent_inputs[3], raw_forest_extent_inputs[4], raw_forest_extent_inputs[5]]
    subprocess.check_call(cmd)

    print "Checking if {} contains any data...".format(tile)
    no_data = uu.check_for_data(tile)

    if no_data:

        print "  No data found. Deleting {}.".format(tile)
        os.remove(tile)

    else:

        print "  Data found in {}. Warping to Hansen tile...".format(tile)

        uu.warp_to_Hansen(tile, '{0}_{1}.tif'.format(tile_id, cn.pattern_Brazil_forest_extent_2000_processed),
                          xmin, ymin, xmax, ymax, 'Byte')



    uu.end_of_fx_summary(start, tile_id, out_pattern)<commit_msg>Trying a different way to create forest extent 2000 tiles for legal amazon loss sensitivity analysis.<commit_after>import glob
import pandas as pd
import datetime
import subprocess
import os
import sys
sys.path.append('../')
import constants_and_names as cn
import universal_util as uu


def merge_warp_forest_extent_tiles(tile_id, raw_forest_extent_inputs, out_pattern, dt):

    # Start time
    start = datetime.datetime.now()

    tile = '{0}_{1}.tif'.format(tile_id, out_pattern)

    print "Getting extent of", tile
    xmin, ymin, xmax, ymax = uu.coords(tile_id)

    print raw_forest_extent_inputs

    cmd = ['gdal_merge.py', '-o', tile,
           '-co', 'COMPRESS=LZW', '-a_nodata', '0', '-n', '0', '-ot', dt,
           '-ps', str(cn.Hansen_res), str(cn.Hansen_res), '-ul_lr', xmax, ymax, xmin, ymin,
           raw_forest_extent_inputs[0], raw_forest_extent_inputs[1], raw_forest_extent_inputs[2],
           raw_forest_extent_inputs[3], raw_forest_extent_inputs[4], raw_forest_extent_inputs[5]]
    subprocess.check_call(cmd)

    print "Checking if {} contains any data...".format(tile)
    no_data = uu.check_for_data(tile)

    if no_data:

        print "  No data found. Deleting {}.".format(tile)
        os.remove(tile)

    else:

        print "  Data found in {}. Warping to Hansen tile...".format(tile)

        uu.warp_to_Hansen(tile, '{0}_{1}.tif'.format(tile_id, cn.pattern_Brazil_forest_extent_2000_processed),
                          xmin, ymin, xmax, ymax, 'Byte')



    uu.end_of_fx_summary(start, tile_id, out_pattern)
{'fraction_non_alphanumeric': 0.1281102891728312, 'fraction_numerical': 0.0121049092131809, 'mean_word_length': 3.413946587537092, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '352713', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1037, 'n_words': 234}