예제 #1
0
    root = exp.data_dir

    for path, case_kws in exp._walk_cases(with_kws=True):
        full_path = os.path.join(root, path)
        try:
            os.makedirs(full_path)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise

        # skip if scenario and historical cases don't match
        if _unmatched_args(**case_kws):
            continue
        if not case_kws['fixedperiod']:
            prefix = exp.case_prefix(**case_kws) + _build_timerange(
                case_kws['period']).start.format('YYYYMMDD') + \
                "-" + _build_timerange(
                case_kws['period']).end.format('YYYYMMDD')
        prefix = exp.case_prefix(**case_kws)
        suffix = exp.output_suffix

        for v in VARS:
            for r in _build_timerange(case_kws['period']).range:
                # @TODO match variable from path
                fn = v + prefix + \
                    r[1].ceil('year').format('YYYY') + SEPARATOR + \
                    r[1].ceil('year').format('YYYY') + suffix
                absolute_filename = os.path.join(full_path, fn)

                print(absolute_filename)
예제 #2
0
    ds['y'] = np.linspace(0, 10, _dims['y'])
    data = rs.normal(size=tuple(_dims[d] for d in _dim_keys))
    ds[varname] = (_dim_keys, data)

    ds.coords['numbers'] = ('time',
                            np.array(range(_dims['time']), dtype='int64'))

    return ds


if __name__ == "__main__":

    root = exp.data_dir

    for path, case_kws in exp._walk_cases(with_kws=True):
        full_path = os.path.join(root, path)
        os.makedirs(full_path, exist_ok=True)

        prefix = exp.case_prefix(**case_kws)
        suffix = exp.output_suffix

        for v in VARS:
            fn = prefix + v + suffix
            absolute_filename = os.path.join(full_path, fn)

            print(absolute_filename)
            ds = _make_dataset(v)
            ds.to_netcdf(absolute_filename)

    exp.to_yaml(os.path.join(root, "sample.yaml"))