Skip to content

Commit

Permalink
remove --gen-csv option
Browse files Browse the repository at this point in the history
  • Loading branch information
carueda committed Mar 19, 2024
1 parent 807a2a3 commit bda72f5
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 28 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

2024-03

- removed `--gen-csv` option (not really used/needed)
- added `--version` option to the programs
- minor code reorg
- enabled poetry
Expand Down
1 change: 0 additions & 1 deletion pbp/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def main():
file_helper=file_helper,
output_dir=opts.output_dir,
output_prefix=opts.output_prefix,
gen_csv=opts.gen_csv,
global_attrs_uri=opts.global_attrs,
set_global_attrs=opts.set_global_attrs,
variable_attrs_uri=opts.variable_attrs,
Expand Down
9 changes: 1 addition & 8 deletions pbp/main_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


def parse_arguments():
description = "PyPAM based processing of Pacific Sound data."
description = "Process ocean audio data archives to daily analysis products of hybrid millidecade spectra using PyPAM."
example = """
Examples:
pbp --json-base-dir=tests/json \\
Expand Down Expand Up @@ -171,13 +171,6 @@ def parse_arguments():
help="Do not remove any downloaded files after use.",
)

parser.add_argument(
"--gen-csv",
default=False,
action="store_true",
help="Also generate CSV version of the result.",
)

parser.add_argument(
"--max-segments",
type=int,
Expand Down
2 changes: 1 addition & 1 deletion pbp/main_json_generator_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def parse_arguments():
description = (
"PyPAM based processing. Generates JSONs with audio metadata for NRS flac files, "
"Generate JSONs with audio metadata for NRS flac files, "
"IcListen wav files, and Soundtrap wav files from either a local directory or gs/s3 bucket."
)
example = """
Expand Down
18 changes: 0 additions & 18 deletions pbp/process_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def __init__(
output_dir: str,
output_prefix: str,
gen_netcdf: bool = True,
gen_csv: bool = False,
global_attrs_uri: Optional[str] = None,
set_global_attrs: Optional[list[list[str]]] = None,
variable_attrs_uri: Optional[str] = None,
Expand All @@ -56,8 +55,6 @@ def __init__(
Output filename prefix.
:param gen_netcdf:
True to generate the netCDF file.
:param gen_csv:
True to also generate CSV version of the result.
:param global_attrs_uri:
URI of JSON file with global attributes to be added to the NetCDF file.
:param set_global_attrs:
Expand Down Expand Up @@ -85,7 +82,6 @@ def __init__(
+ f"\n output_dir: {output_dir}"
+ f"\n output_prefix: {output_prefix}"
+ f"\n gen_netcdf: {gen_netcdf}"
+ f"\n gen_csv: {gen_csv}"
+ f"\n global_attrs_uri: {global_attrs_uri}"
+ f"\n set_global_attrs: {set_global_attrs}"
+ f"\n variable_attrs_uri: {variable_attrs_uri}"
Expand All @@ -104,7 +100,6 @@ def __init__(
self.output_dir = output_dir
self.output_prefix = output_prefix
self.gen_netcdf = gen_netcdf
self.gen_csv = gen_csv

self.metadata_helper = MetadataHelper(
self.logger,
Expand Down Expand Up @@ -238,11 +233,6 @@ def process_day(self, date: str) -> Optional[ProcessDayResult]:
save_dataset_to_netcdf(self.logger, ds_result, nc_filename)
generated_filenames.append(nc_filename)

if self.gen_csv:
csv_filename = f"{basename}.csv"
save_dataset_to_csv(self.logger, ds_result, csv_filename)
generated_filenames.append(csv_filename)

self.file_helper.day_completed()

return ProcessDayResult(generated_filenames, ds_result)
Expand Down Expand Up @@ -330,11 +320,3 @@ def save_dataset_to_netcdf(logger: PbpLogger, ds: xr.Dataset, filename: str) ->
logger.error(error)
print(error)
return False


def save_dataset_to_csv(logger: PbpLogger, ds: xr.Dataset, filename: str):
logger.info(f" - saving dataset to: {filename}")
try:
ds.to_pandas().to_csv(filename, float_format="%.1f")
except Exception as e: # pylint: disable=broad-exception-caught
logger.error(f"Unable to save {filename}: {e}")

0 comments on commit bda72f5

Please sign in to comment.