Skip to content

Commit

Permalink
do not write CDIP acknowledgment for generic inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dionhaefner committed May 14, 2020
1 parent 0abda56 commit 00c0316
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
17 changes: 16 additions & 1 deletion fowd/cdip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
)
6 changes: 3 additions & 3 deletions fowd/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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}')

Expand Down
17 changes: 6 additions & 11 deletions fowd/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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='[email protected]',
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',
Expand All @@ -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)])),
Expand Down

0 comments on commit 00c0316

Please sign in to comment.