Exemple #1
0
def main(output_path, delta, ncml_file=None, glob_string=None, apply_to_members=None, hard_start=None, hard_end=None):
    if glob_string is not None:
        collection = Collection.from_glob(glob_string, ncml=ncml_file)
    elif ncml_file is not None:
        collection = Collection.from_ncml_file(ncml_file, apply_to_members=apply_to_members)

    if delta.years > 0:
        starting = collection.aggregation.starting.replace(microsecond=0, second=0, minute=0, hour=0, day=1, month=1)
    elif delta.months > 0:
        starting = collection.aggregation.starting.replace(microsecond=0, second=0, minute=0, hour=0, day=1)
    elif delta.days > 0:
        starting = collection.aggregation.starting.replace(microsecond=0, second=0, minute=0, hour=0)

    windows = collection.bins(delta=delta, starting=starting, hard_start=hard_start, hard_end=hard_end)

    # Create output directory
    if not os.path.exists(output_path):
        os.makedirs(output_path)

    for i, window in enumerate(windows):
        # Create a file name
        starting = window.starting.strftime("%Y%m%dT%H%M")
        ending   = window.ending.strftime("%Y%m%dT%H%M")
        if starting == ending:
            file_name = "{0}.nc".format(starting)
        else:
            file_name = "{0}_TO_{1}.nc".format(starting, ending)
        output_file = os.path.join(output_path, file_name)

        pyaxiomlogger.info("Combining ({0}/{1}) - {2} files into {3}".format(i+1, len(windows), len(window.members), output_file))
        Collection.combine(members=window.members, output_file=output_file)

    return 0
 def setUp(self):
     glob_string = os.path.join(os.path.dirname(__file__), "resources/coamps/cencoos_4km/wnd_tru/**/*.nc")
     ncml        = """<?xml version="1.0" encoding="UTF-8"?>
     <netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
         <attribute name="title" value="changed" />
     </netcdf>
     """
     self.c = Collection.from_glob(glob_string, ncml=ncml)
Exemple #3
0
def main(output_path,
         delta,
         ncml_file=None,
         glob_string=None,
         apply_to_members=None,
         hard_start=None,
         hard_end=None):
    if glob_string is not None:
        collection = Collection.from_glob(glob_string, ncml=ncml_file)
    elif ncml_file is not None:
        collection = Collection.from_ncml_file(
            ncml_file, apply_to_members=apply_to_members)

    if delta.years > 0:
        starting = collection.aggregation.starting.replace(microsecond=0,
                                                           second=0,
                                                           minute=0,
                                                           hour=0,
                                                           day=1,
                                                           month=1)
    elif delta.months > 0:
        starting = collection.aggregation.starting.replace(microsecond=0,
                                                           second=0,
                                                           minute=0,
                                                           hour=0,
                                                           day=1)
    elif delta.days > 0:
        starting = collection.aggregation.starting.replace(microsecond=0,
                                                           second=0,
                                                           minute=0,
                                                           hour=0)

    windows = collection.bins(delta=delta,
                              starting=starting,
                              hard_start=hard_start,
                              hard_end=hard_end)

    # Create output directory
    if not os.path.exists(output_path):
        os.makedirs(output_path)

    for i, window in enumerate(windows):
        # Create a file name
        starting = window.starting.strftime("%Y%m%dT%H%M")
        ending = window.ending.strftime("%Y%m%dT%H%M")
        if starting == ending:
            file_name = "{0}.nc".format(starting)
        else:
            file_name = "{0}_TO_{1}.nc".format(starting, ending)
        output_file = os.path.join(output_path, file_name)

        pyaxiomlogger.info("Combining ({0}/{1}) - {2} files into {3}".format(
            i + 1, len(windows), len(window.members), output_file))
        Collection.combine(members=window.members, output_file=output_file)

    return 0
Exemple #4
0
 def setUp(self):
     glob_string = os.path.join(
         os.path.dirname(__file__),
         "resources/coamps/cencoos_4km/wnd_tru/**/*.nc")
     ncml = """<?xml version="1.0" encoding="UTF-8"?>
     <netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2">
         <attribute name="title" value="changed" />
     </netcdf>
     """
     self.c = Collection.from_glob(glob_string, ncml=ncml)
Exemple #5
0
 def setUp(self):
     glob_string = os.path.join(
         os.path.dirname(__file__),
         "resources/coamps/cencoos_4km/wnd_tru/10m/*.nc")
     self.c = Collection.from_glob(glob_string)
 def setUp(self):
     glob_string = os.path.join(os.path.dirname(__file__), "resources/coamps/cencoos_4km/wnd_tru/10m/*.nc")
     self.c = Collection.from_glob(glob_string)