Exemple #1
0
def diff_file_stats(filename):
    """
    Print some statistics for diff file *filename*.
    
    """
    from runutils import parse_scene
    import sys
    write = sys.stdout.write
    write('Scene: %s %s %d' % parse_scene(filename.replace('match--', '')))

    lwp_diff, restrictions, lat = get_diff_data([filename], ['latitudes'])

    #print("Restrictions: %s" % '; '.join(restrictions))
    write(' ¤ Valid pixels: % 6d' % lwp_diff.size)
    write(' ¤ Latitudes: %5.2f - %5.2f' % (lat.min(), lat.max()))
    print('')
Exemple #2
0
    except (IndexError, ValueError):
        raise ParseError("%r !~ YYYYMMDDhhmm" % s)

    return datetime(year, month, day, hour, minute)


def usage():
    print("Usage: %s YYYYMMDDhhmm [...]\n"
          "or     %s scene [...]" % sys.argv[0])
    sys.exit(-1)


if __name__ == '__main__':
    if len(sys.argv) < 2:
        usage()

    times = []
    for dt_string in sys.argv[1:]:
        try:
            times.append(parse_datetime_arg(dt_string))
        except ParseError, err:
            try:
                from runutils import parse_scene
                satname, _datetime, orbit = parse_scene(
                    os.path.basename(dt_string))
                times.append(_datetime)
            except ValueError:
                print(err)
                usage()
    fetch_for_times(times)
Exemple #3
0
def main(args=None):
    """
    Process command line options and run matchup and validation.
    
    If *args* is provided, it should be a list of command line arguments (e.g.
    sys.argv[1:]).
    
    For a complete usage description, run 'python process_master -h'.
    
    """
    import find_crosses
    import argparse
    parser = argparse.ArgumentParser()
    group = parser.add_mutually_exclusive_group(required=True)
    parser.add_argument('--mode',
                        '-M',
                        type=str,
                        required=False,
                        choices=config.ALLOWED_MODES,
                        help=("Run validation software in MODE "))
    parser.add_argument(
        '--reprocess',
        '-r',
        const=True,
        nargs='?',
        required=False,
        help="Disregard any previously generated Cloudsat- and "
        "Calipso-AVHRR matchup files.")
    parser.add_argument('-d',
                        '--debug',
                        const=True,
                        nargs='?',
                        required=False,
                        help="Get debug logging")
    group.add_argument(
        '--pps_okay_scene',
        '-os',
        help="Interpret arguments as PPS okay scenes instead of "
        "sno_output_files (e.g. noaa19_20101201_1345_27891*)")
    group.add_argument('--pps_product_file',
                       '-pf',
                       help="Interpret arguments as inputfile with "
                       "list of pps files")
    group.add_argument('--cci_product_file',
                       '-cf',
                       help="Interpret arguments as inputfile with "
                       "list of cci files")
    group.add_argument('--maia_product_file',
                       '-mf',
                       help="Interpret arguments as inputfile with "
                       "list of maia files")
    group.add_argument('--sno_file',
                       '-sf',
                       help="Interpret arguments as sno_output_file")

    options = parser.parse_args()

    if options.mode is not None:
        run_modes = [options.mode]
    else:
        run_modes = config.ALLOWED_MODES

    reprocess = False
    if options.reprocess is not None:
        reprocess = options.reprocess

    config.DEBUG = options.debug
    if options.debug:
        import logging
        logging.getLogger().setLevel(logging.DEBUG)

    matchups = []
    if options.pps_okay_scene:
        # Simulate crosses from PPS scenes
        from find_crosses import Cross
        from runutils import parse_scene
        scene = options.pps_okay_scene
        satname, time, orbit = parse_scene(scene)  #@UnusedVariable
        matchups.append(Cross(satname, '', time, time, -999, -999))
    elif options.sno_file is not None:
        if config.USE_ORBITS_THAT_STARTS_EXACTLY_AT_CROSS:
            print config.USE_ORBITS_THAT_STARTS_EXACTLY_AT_CROSS
            raise InputError(
                " Expected " +
                "USE_ORBITS_THAT_STARTS_EXACTLY_AT_CROSS=False (config.py) ")
        sno_output_file = options.sno_file
        found_matchups = find_crosses.parse_crosses_file(sno_output_file)
        if len(found_matchups) == 0:
            logger.warning("No matchups found in SNO output file %s" %
                           sno_output_file)
            if options.debug is True:
                raise Warning()
        else:
            matchups.extend(found_matchups)
    elif options.pps_product_file is not None:
        from find_crosses import Cross
        from runutils import parse_scenesfile_v2014
        pps_output_file = options.pps_product_file
        read_from_file = open(pps_output_file, 'r')
        for line in read_from_file:
            if line.rstrip() in "":
                pass
            else:
                satname, time = parse_scenesfile_v2014(line)
                matchups.append(Cross(satname, '', time, time, -999, -999))
    elif options.cci_product_file is not None:
        from find_crosses import Cross
        from runutils import parse_scenesfile_cci
        cci_output_file = options.cci_product_file
        read_from_file = open(cci_output_file, 'r')
        for line in read_from_file:
            if line.rstrip() in "":
                pass
            else:
                satname, time = parse_scenesfile_cci(line)
                matchups.append(Cross(satname, '', time, time, -999, -999))
    elif options.maia_product_file is not None:
        from find_crosses import Cross
        from runutils import parse_scenesfile_maia
        maia_output_file = options.maia_product_file
        read_from_file = open(maia_output_file, 'r')
        for line in read_from_file:
            if line.rstrip() in "":
                pass
            else:
                satname, time = parse_scenesfile_maia(line)
                matchups.append(Cross(satname, '', time, time, -999, -999))

    process_matchups(matchups, run_modes, reprocess, options.debug)

    return 0