diff --git a/fowd/cdip.py b/fowd/cdip.py index 7086195..e705dd3 100644 --- a/fowd/cdip.py +++ b/fowd/cdip.py @@ -23,6 +23,17 @@ logger = logging.getLogger(__name__) +EXTRA_METADATA = dict( + contributor_name='CDIP, CDBW/USACE', + contributor_role='station operation, station funding', + acknowledgment=( + 'CDIP is supported by the U.S. Army Corps of Engineers (USACE) and the California ' + 'Department of Boating and Waterways (CDBW). The instrument that collected this ' + 'dataset was funded by CDBW/USACE and operated by CDIP.' + ), +) + + # dataset-specific helpers def mask_invalid(data): @@ -263,4 +274,8 @@ def handle_result(i, result, pbar): out_file = os.path.join(out_folder, f'fowd_cdip_{station_id}.nc') logger.info('Writing output to %s', out_file) station_name = f'CDIP_{station_id}' - write_records(wave_records, out_file, station_name, include_direction=True) + + write_records( + wave_records, out_file, station_name, + include_direction=True, extra_metadata=EXTRA_METADATA + ) diff --git a/fowd/cli.py b/fowd/cli.py index 8a11b63..3988f62 100644 --- a/fowd/cli.py +++ b/fowd/cli.py @@ -102,14 +102,14 @@ def run_tests(out_folder): os.makedirs(out_folder, exist_ok=True) - click.echo('Running unit tests...') + click.echo('Running unit tests ...') exit_code = pytest.main([ '-x', os.path.join(os.path.dirname(__file__), 'tests') ]) click.echo('') - click.echo('Running sanity checks...') + click.echo('Running sanity checks ...') run_all(out_folder) click.echo(f'Sanity check results written to {out_folder}') click.echo(click.style('Make sure to check whether outputs are as expected.', bold=True)) @@ -127,7 +127,7 @@ def postprocess(qc_infile, out_folder): if out_folder is None: out_folder = tempfile.mkdtemp(prefix='fowd_qc_') - click.echo('Plotting sea states...') + click.echo('Plotting QC records ...') plot_qc(qc_infile, out_folder) click.echo(f'Results written to {out_folder}') diff --git a/fowd/output.py b/fowd/output.py index 6c7f023..f6d082e 100644 --- a/fowd/output.py +++ b/fowd/output.py @@ -438,7 +438,8 @@ ) -def write_records(wave_records, filename, station_name, include_direction=False): +def write_records(wave_records, filename, station_name, extra_metadata=None, + include_direction=False): """Write given records to netCDF4""" dataset_metadata = dict( @@ -460,8 +461,6 @@ def write_records(wave_records, filename, station_name, include_direction=False) creator_url='https://climate-geophysics.nbi.ku.dk/research/oceanography/', creator_email='dion.haefner@nbi.ku.dk', institution='Niels Bohr Institute, University of Copenhagen', - contributor_name='CDIP, CDBW/USACE', - contributor_role='station operation, station funding', geospatial_lat_units='degrees_north', geospatial_lat_resolution=1e-5, geospatial_lon_units='degrees_east', @@ -473,16 +472,12 @@ def write_records(wave_records, filename, station_name, include_direction=False) time_coverage_end=str(wave_records['wave_end_time'].max()), source='insitu observations', license='These data may be redistributed and used without restriction.', - acknowledgment=( - 'CDIP is supported by the U.S. Army Corps of Engineers (USACE) and the California ' - 'Department of Boating and Waterways (CDBW). The instrument that collected this ' - 'dataset was funded by CDBW/USACE and operated by CDIP.' - ), - comment=( - '' - ), ) + if extra_metadata is not None: + for key, val in extra_metadata.items(): + dataset_metadata[key] = ''.join([dataset_metadata.get(key, ''), str(val)]) + dimension_data = ( # (name, dtype, data) ('meta_station_name', str, np.array([np.string_(station_name)])),