pyreshaper.reshaper module

The module containing the Reshaper class

This is the main reshaper module. This is where the specific operations are defined. Currently, only one operation has been implemented (i.e., the time-slice to time-series operation).

Copyright 2020 University Corporation for Atmospheric Research

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class pyreshaper.reshaper.Reshaper(specifier, serial=False, verbosity=1, wmode='w', once=False, simplecomm=None)

Bases: object

The time-slice to time-series Reshaper class

This is the class that defines how the time-slice to time-series reshaping operation is to be performed.

convert(output_limit=0, rchunks=None, wchunks=None)

Method to perform the Reshaper’s designated operation.

In this case, convert a list of time-slice files to time-series files.

Parameters:
output_limit (int): Limit on the number of output (time-series) files to write during the

convert() operation. If set to 0, no limit is placed. This limits the number of output files produced by each processor in a parallel run.

rchunks (dict): A dictionary of dimension names mapped to reading chunk sizes along that named

dimension

wchunks (dict): A dictionary of dimension names mapped to writing chunk sizes along that named

dimension

print_diagnostics()

Print out timing and I/O information collected up to this point

pyreshaper.reshaper.create_reshaper(specifier, serial=False, verbosity=1, wmode='w', once=False, simplecomm=None)

Factory function for Reshaper class instantiations.

Parameters:
specifier (Specifier): An instantiation of a Specifier class that

defines the type of operation to be performed. (That is, a Slice2SeriesSpecifier will invoke the creation of a matching Slice2SeriesReshaper object.) Alternatively, this can be a list of Specifier objects, or dictionary of named Specifier objects. In this case, a reshaper will be created for each specifier in the list, and each reshaper will be created and run in sequence.

serial (bool): True or False, indicating whether the Reshaper object

should perform its operation in serial (True) or parallel (False).

verbosity (int): Level of printed output (stdout). A value of 0 means

no output, and a higher value means more output. The default value is 1.

wmode (str): The mode to use for writing output. Can be ‘w’ for

normal write operation, ‘s’ to skip the output generation for existing time-series files, ‘o’ to overwrite existing time-series files, ‘a’ to append to existing time-series files.

once (bool): True or False, indicating whether the Reshaper should

write all metadata to a ‘once’ file (separately).

simplecomm (SimpleComm): A SimpleComm object to handle the parallel

communication, if necessary

Returns:

Reshaper: An instance of the Reshaper object requested