Skip to content

Commit

Permalink
rename desi_reformat_proctables and desi_reformat_exptables
Browse files Browse the repository at this point in the history
  • Loading branch information
akremin committed Sep 20, 2024
1 parent 84f44af commit 7e65bcb
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 82 deletions.
40 changes: 0 additions & 40 deletions bin/desi_reformat_exposure_tables

This file was deleted.

12 changes: 12 additions & 0 deletions bin/desi_reformat_exptables
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python
# coding: utf-8

## Import some helper functions, you can see their definitions by uncomenting the bash shell command
from desispec.scripts.reformat_exptables import get_parser, reformat_exposure_tables


if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args()

reformat_exposure_tables(**args.__dict__)
33 changes: 0 additions & 33 deletions bin/desi_reformat_processing_tables

This file was deleted.

14 changes: 14 additions & 0 deletions bin/desi_reformat_proctables
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env python
# coding: utf-8

## Import some helper functions, you can see their definitions by uncomenting the bash shell command
from desispec.scripts.reformat_proctables import get_parser, reformat_processing_tables




if __name__ == '__main__':
parser = get_parser()
args = parser.parse_args()

reformat_processing_tables(**args.__dict__)
28 changes: 26 additions & 2 deletions py/desispec/scripts/reformat_exptables.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
desispec.scripts.updateexptables
desispec.scripts.reformat_exptables
================================
"""
import argparse
import os
import sys
import numpy as np
Expand All @@ -20,8 +21,31 @@
from desispec.scripts.exposuretable import create_exposure_tables


def get_parser():
"""
Creates an arguments parser for the desi_reformat_exposure_tables script
"""
parser = argparse.ArgumentParser(usage = "{prog} [options]")
parser.add_argument("-n", "--nights", type=str, default=None, help="nights as comma separated string")
parser.add_argument("--night-range", type=str, default=None, help="comma separated pair of nights in form YYYYMMDD,YYYYMMDD"+\
"for first_night,last_night specifying the beginning"+\
"and end of a range of nights to be generated. "+\
"last_night should be inclusive.")
parser.add_argument("--obstypes", type=str, default=None, help="comma separated list of exposure types to include in "+\
"the exposure table, e.g. science,arc,flat,dark,zero, ...")
parser.add_argument("-i", "--path-to-data", type=str, default=None, help="path to the raw input data")
parser.add_argument("-o","--exp-table-path", type=str, default=None, help="path to save exposure tables, without monthly subdirectory")
parser.add_argument("--orig-filetype", type=str, default='csv', help="format type for original exposure tables")
parser.add_argument("--out-filetype", type=str, default='csv', help="format type for output exposure tables")
parser.add_argument("--verbose", action="store_true", help="print verbose output")
parser.add_argument("--dry-run", action="store_true",
help="Perform a dry run, printing the changes that would be made and the final output table "+
"but not overwriting the actual files on disk.")
parser.add_argument("--no-specprod", action="store_true", help="Create exposure table in repository location "+\
"rather than the SPECPROD location.")
return parser

def update_exposure_tables(nights=None, night_range=None, path_to_data=None,
def reformat_exposure_tables(nights=None, night_range=None, path_to_data=None,
exp_table_path=None, obstypes=None, orig_filetype='csv',
out_filetype='csv', verbose=False, no_specprod=False,
dry_run=False):
Expand Down
31 changes: 24 additions & 7 deletions py/desispec/scripts/reformat_proctables.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""
desispec.scripts.updateexptables
desispec.scripts.reformat_proctables
================================
"""
import argparse
import os
import glob
import sys
Expand All @@ -19,24 +20,40 @@
from desispec.scripts.exposuretable import create_exposure_tables



def update_processing_tables(nights=None, night_range=None, orig_filetype='csv',
def get_parser():
"""
Creates an arguments parser for the desi_reformat_processing_tables script
"""
parser = argparse.ArgumentParser(usage = "{prog} [options]")
parser.add_argument("-n", "--nights", type=str, default=None, help="nights as comma separated string")
parser.add_argument("--night-range", type=str, default=None, help="comma separated pair of nights in form YYYYMMDD,YYYYMMDD"+\
"for first_night,last_night specifying the beginning"+\
"and end of a range of nights to be generated. "+\
"last_night should be inclusive.")
parser.add_argument("--orig-filetype", type=str, default='csv', help="format type for original exposure tables")
parser.add_argument("--out-filetype", type=str, default='csv', help="format type for output exposure tables")
parser.add_argument("--dry-run", action="store_true",
help="Perform a dry run, printing the changes that would be made and the final output table "+
"but not overwriting the actual files on disk.")
return parser

def reformat_processing_tables(nights=None, night_range=None, orig_filetype='csv',
out_filetype='csv', dry_run=False):
"""
Generates updated processing tables for the nights requested. Requires
a current processing table to exist on disk.
Args:
nights: str, int, or comma separated list. The night(s) to generate
procesing tables for.
processing tables for.
night_range: str. comma separated pair of nights in form
YYYYMMDD,YYYYMMDD for first_night,last_night
specifying the beginning and end of a range of
nights to be generated. first_night and last_night are
inclusive.
orig_filetype: str. The file extension (without the '.') of the exposure
orig_filetype: str. The file extension (without the '.') of the processing
tables.
out_filetype: str. The file extension for the outputted exposure tables
out_filetype: str. The file extension for the outputted processing tables
(without the '.').
Returns:
Expand Down Expand Up @@ -174,4 +191,4 @@ def update_processing_tables(nights=None, night_range=None, orig_filetype='csv',
## Flush the outputs
sys.stdout.flush()
sys.stderr.flush()
print("Exposure table regenerations complete")
print("Processing table regenerations complete")

0 comments on commit 7e65bcb

Please sign in to comment.