The figure below provides an overview of the data loading workflow:
The key files within the directories in order of importance are:
- data.py where:
a) Individual forecast variables are loaded underload_fcst, and all variables are loaded by callingload_fcst_stack.
b) constants (topography and land-sea mask) are loaded underload_hires_constants.
c) truth data is loaded underload_truth_and_mask.
d) Fcst and truth are loaded in for a given date and time inload_fcst_truth_batch. - data_generator.py which has a
DataGeneratorclass that callsload_fcst_truth_batchat different dates and times through iterative__getitem__calls. This is an important function as it does not load in all data to memory at once but (in Nishadh's words) allows streaming. - tfrecords_generator.py which:
a) creates tfrecords by callingwrite_data.
b) during training it loads the batches from the tfrecords via thecreate_mixed_datasetthat is called within its ownDataGeneratorfunction.
Before starting with anything, you need to check that all data paths are correctly set by going into the config sub-directory and adjusting the paths by:
- Making sure the paths to read-in data (
TRUTH_PATH,FCST_PATHandCONSTANTS_PATH) as well as write tfrecords to (tfrecords_path) in data_paths.yaml are correct. - Making sure that the correct
data_pathoption is set in local_config.yaml.
Creating the training data needed to train the cGAN, require the following steps:
- Creating the forecast normalisation constants consisting of the min, max, mean and standard deviation of each variable considered. This is necessary as for fitting any AI model, values need to be normalised.
- Setting up the data generator and visualising data to make sure it is loaded in correctly.
- Creating the tfrecord files
An example notebook is provided under the example_notebooks directory called create_tfrecords.ipynb which allows us to follow these steps.