Ejemplo n.º 1
0
def check_args_preproc(args):
    """Ensure preprocessor parser arguments are valid."""
    from pyorac.definitions import FileName
    from pyorac.local_defaults import auxiliaries, global_attributes
    from pyorac.util import get_repository_revision

    # Add global attributes
    global_attributes.update({key: val for key, val in args.global_att})
    args.__dict__.update(global_attributes)

    # Insert auxilliary locations
    auxiliaries.update({key: val for key, val in args.aux})
    args.__dict__.update(auxiliaries)

    try:
        # When using ecmwf_dir to set a single directory
        args.ggam_dir = args.ecmwf_dir
        args.ggas_dir = args.ecmwf_dir
        args.spam_dir = args.ecmwf_dir
    except:
        pass

    # Limit should either be all zero or all non-zero.
    limit_check = args.limit[0] == 0
    for limit_element in args.limit[1:]:
        if (limit_element == 0) ^ limit_check:
            warnings.warn('All elements of --limit should be non-zero.',
                          OracWarning,
                          stacklevel=2)

    # Update FileName class
    if args.revision is None:
        try:
            args.revision = args.File.revision
        except AttributeError:
            args.revision = get_repository_revision()
    if "revision" not in args.File.__dict__:
        args.File.revision = args.revision
    if "processor" not in args.File.__dict__:
        args.File.processor = args.processor
    if "project" not in args.File.__dict__:
        args.File.project = args.project
    if "product_name" not in args.File.__dict__:
        args.File.product_name = args.product_name

    if args.File.predef and args.l1_land_mask and not args.no_predef:
        raise ValueError("Do not set --l1_land_mask while using predefined "
                         "geostationary geolocation.")

    if not isdir(args.atlas_dir):
        raise FileMissing('RTTOV Atlas directory', args.atlas_dir)
    #if not isfile(args.calib_file):
    #    raise FileMissing('AATSR calibration file', args.calib_file)
    if not isdir(args.coef_dir):
        raise FileMissing('RTTOV coefficients directory', args.coef_dir)
    if not isdir(args.emis_dir):
        raise FileMissing('RTTOV emissivity directory', args.emis_dir)
    if not isdir(args.emos_dir):
        raise FileMissing('EMOS temporary directory', args.emos_dir)
Ejemplo n.º 2
0
    def revision(self):
        """Revision number"""
        from pyorac.util import get_repository_revision

        try:
            return self._revision
        except AttributeError:
            return get_repository_revision()
Ejemplo n.º 3
0
args_main(pars)
args_postproc(pars)
orig_args = pars.parse_args()

orig_args = check_args_regress(orig_args)

if orig_args.in_dir is None:
    orig_args.in_dir = [defaults.data_dir + '/testinput']
if orig_args.out_dir:
    base_out_dir = orig_args.out_dir
else:
    base_out_dir = defaults.data_dir +'/testoutput'

# Increment version number (as this is usually run on uncommited code)
if orig_args.revision is None:
    orig_args.revision = get_repository_revision()

    if not orig_args.benchmark:
        orig_args.revision += 1


try:
    for test in orig_args.tests:
        colour_print(test, COLOURING['header'])
        args = deepcopy(orig_args)

        # Set filename to be processed and output folder
        args.out_dir = os.path.join(base_out_dir, test)
        try:
            args.target, args.limit, args.preset_settings = REGRESSION_TESTS[test]
        except KeyError: