<commit_before>"""Converts storm-centered radar images from GridRad to MYRORSS format."""

import argparse
import numpy
from gewittergefahr.gg_utils import radar_utils
from gewittergefahr.gg_utils import time_conversion
from gewittergefahr.deep_learning import input_examples
from gewittergefahr.deep_learning import training_validation_io as trainval_io

LL_SHEAR_OPERATION_DICT = {
    input_examples.RADAR_FIELD_KEY: radar_utils.VORTICITY_NAME,
    input_examples.MIN_HEIGHT_KEY: 0,
    input_examples.MAX_HEIGHT_KEY: 2000,
    input_examples.OPERATION_NAME_KEY: input_examples.MAX_OPERATION_NAME
}

ML_SHEAR_OPERATION_DICT = {
    input_examples.RADAR_FIELD_KEY: radar_utils.VORTICITY_NAME,
    input_examples.MIN_HEIGHT_KEY: 3000,
    input_examples.MAX_HEIGHT_KEY: 6000,
    input_examples.OPERATION_NAME_KEY: input_examples.MAX_OPERATION_NAME
}

VORTICITY_TO_AZ_SHEAR = 2.

INPUT_DIR_ARG_NAME = 'input_storm_image_dir_name'
FIRST_DATE_ARG_NAME = 'first_spc_date_string'
LAST_DATE_ARG_NAME = 'last_spc_date_string'
RESOLUTION_FACTOR_ARG_NAME = 'resolution_factor'
OUTPUT_DIR_ARG_NAME = 'output_storm_image_dir_name'

# TODO(thunderhoser): Allow this to be done for shuffled example files?

INPUT_DIR_HELP_STRING = (
    'Name of top-level directory with input images (in GridRad format).  Files '
    'therein will be found by `input_examples.find_example_file` and read by '
    '`input_examples.read_example_file`.')

SPC_DATE_HELP_STRING = (
    'SPC date (format "yyyymmdd").  Images will be converted for all SPC dates '
    'in period `{0:s}`...`{1:s}`.'
).format(FIRST_DATE_ARG_NAME, LAST_DATE_ARG_NAME)

NUM_ROWS_HELP_STRING = (
    'Number of rows in new (MYRORSS-style) reflectivity grid.  Azimuthal-shear '
    'grid will have twice as many rows.')

RESOLUTION_FACTOR_HELP_STRING = (
    'Resolution factor.  Horizontal resolution of reflectivity grids will be '
    'upsampled this factor.  Horizontal resolution of az-shear grids will be '
    'upsampled by twice this factor.')

OUTPUT_DIR_HELP_STRING = (
    'Name of top-level directory for output images (in MYRORSS format).  Files '
    'will be written by `input_examples.write_example_file` to locations therein '
    'determined by `input_examples.find_example_file`.')

INPUT_ARG_PARSER = argparse.ArgumentParser()
INPUT_ARG_PARSER.add_argument(<commit_msg>Tweaked input-arg names in storm_images_gridrad_to_myrorss.py.<commit_after>"""Converts storm-centered radar images from GridRad to MYRORSS format."""

import argparse
import numpy
from gewittergefahr.gg_utils import radar_utils
from gewittergefahr.gg_utils import time_conversion
from gewittergefahr.deep_learning import input_examples
from gewittergefahr.deep_learning import training_validation_io as trainval_io

LL_SHEAR_OPERATION_DICT = {
    input_examples.RADAR_FIELD_KEY: radar_utils.VORTICITY_NAME,
    input_examples.MIN_HEIGHT_KEY: 0,
    input_examples.MAX_HEIGHT_KEY: 2000,
    input_examples.OPERATION_NAME_KEY: input_examples.MAX_OPERATION_NAME
}

ML_SHEAR_OPERATION_DICT = {
    input_examples.RADAR_FIELD_KEY: radar_utils.VORTICITY_NAME,
    input_examples.MIN_HEIGHT_KEY: 3000,
    input_examples.MAX_HEIGHT_KEY: 6000,
    input_examples.OPERATION_NAME_KEY: input_examples.MAX_OPERATION_NAME
}

VORTICITY_TO_AZ_SHEAR = 2.

INPUT_DIR_ARG_NAME = 'input_example_dir_name'
FIRST_DATE_ARG_NAME = 'first_spc_date_string'
LAST_DATE_ARG_NAME = 'last_spc_date_string'
RESOLUTION_FACTOR_ARG_NAME = 'resolution_factor'
OUTPUT_DIR_ARG_NAME = 'output_example_dir_name'

# TODO(thunderhoser): Allow this to be done for shuffled example files?

INPUT_DIR_HELP_STRING = (
    'Name of top-level directory with input images (in GridRad format).  Files '
    'therein will be found by `input_examples.find_example_file` and read by '
    '`input_examples.read_example_file`.')

SPC_DATE_HELP_STRING = (
    'SPC date (format "yyyymmdd").  Images will be converted for all SPC dates '
    'in period `{0:s}`...`{1:s}`.'
).format(FIRST_DATE_ARG_NAME, LAST_DATE_ARG_NAME)

NUM_ROWS_HELP_STRING = (
    'Number of rows in new (MYRORSS-style) reflectivity grid.  Azimuthal-shear '
    'grid will have twice as many rows.')

RESOLUTION_FACTOR_HELP_STRING = (
    'Resolution factor.  Horizontal resolution of reflectivity grids will be '
    'upsampled this factor.  Horizontal resolution of az-shear grids will be '
    'upsampled by twice this factor.')

OUTPUT_DIR_HELP_STRING = (
    'Name of top-level directory for output images (in MYRORSS format).  Files '
    'will be written by `input_examples.write_example_file` to locations therein '
    'determined by `input_examples.find_example_file`.')

INPUT_ARG_PARSER = argparse.ArgumentParser()
INPUT_ARG_PARSER.add_argument(
{'fraction_non_alphanumeric': 0.07323285926554872, 'fraction_numerical': 0.006792613033326258, 'mean_word_length': 5.526315789473684, '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': '2888835', 'n_tokens_mistral': 1698, 'n_tokens_neox': 1616, 'n_words': 361}