diff --git a/beast/observationmodel/phot.py b/beast/observationmodel/phot.py index ae67d38f..0f2ea0b9 100644 --- a/beast/observationmodel/phot.py +++ b/beast/observationmodel/phot.py @@ -16,7 +16,7 @@ """ import sys import numpy - +import argparse import tables from scipy.integrate import trapz @@ -579,11 +579,11 @@ class __newFilterTable__(tables.IsDescription): def append_filter( lamb, - flux, + throughput, tablename, observatory, instrument, - name, + filtername, comment=None, filterLib=__default__, updateVegaLib=True, @@ -594,10 +594,10 @@ def append_filter( Parameters ---------- lamb: ndarray(dtype=float) - wavelength of the filter definition + wavelength of the filter definition in Angstrom - flux: ndarray(dtype=float) - transimission of the filter + throughput: ndarray(dtype=float) + total throughput of the filter tablename: str table name in the library @@ -606,9 +606,9 @@ def append_filter( observatory of the filter (Ground, HST, Spitzer, ...) instrument: str - instrument associated with the filter + instrument associated with the filter (WFC3, ACS, ...) - name: str + filtername: str name of the filter comment: str, optional @@ -629,7 +629,7 @@ def append_filter( return # Gen Filter object including relevant details - filtInst = list(filter(lamb, flux, name=name)) + filtInst = Filter(lamb, throughput, name=filtername) # Add a new line in the content table newRow = contentTab.row newRow["TABLENAME"] = tablename @@ -659,7 +659,7 @@ def append_filter( newTab.flush() ftab.flush() ftab.close() - print("% {0}: Filter {1} added to {2}".format(sys.argv[0], name, filterLib)) + print("% {0}: Filter {1} added to {2}".format(sys.argv[0], filtername, filterLib)) if updateVegaLib: appendVegaFilter(filtInst) @@ -733,3 +733,44 @@ def appendVegaFilter(filtInst, VegaLib=__default_vega__): sedTab.flush() vtab.close() print("% {0}: Filter {1} added to {2}".format(sys.argv[0], filtInst.name, VegaLib)) + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "filter_throughput_curve", + type=str, + default=None, + help="filename of filter throughput curve to be added into the BEAST filter library", + ) + parser.add_argument( + "--tablename", + type=str, + help="Table name for the filter", + ) + parser.add_argument( + "--observatory", + type=str, + help="Observatory for the filter (e.g., HST, GALEX)", + ) + parser.add_argument( + "--instrument", + type=str, + help="Instrument associated with the filter (WFC3, ACS, ...)", + ) + parser.add_argument( + "--filtername", + type=str, + help="Name for the filter", + ) + + args = parser.parse_args() + + if args.filter_throughput_curve: + lamb, throughput = numpy.loadtxt(args.filter_throughput_curve, usecols=(0, 1), + unpack=True) + append_filter(lamb, throughput, args.tablename, args.observatory, args.instrument, + args.filtername) + + if not any(vars(args).values()): + parser.print_help() diff --git a/docs/append_filters.rst b/docs/append_filters.rst new file mode 100644 index 00000000..6ca74971 --- /dev/null +++ b/docs/append_filters.rst @@ -0,0 +1,22 @@ +############## +Append filters +############## + +Users can add any filters into their local ``beast/libs/filters.hd5``. +The list of default filters in the BEAST filter library can be found ``_. + +If you need to include fluxes in particular bands in your SED fitting or BEAST +predictions but those particular bands do not exist in the BEAST filter library, +you should append those filters to the BEAST filter library before generating +your physics model grid. To do this, you need an ascii file that has two columns: +wavelegnth in angstrom and thoughput. The BEAST filter library requires basic information +about the filter. This includes the tablename for the filter information (e.g., HST_WFC3_F275W), +observatorty associated with the filter (e.g., HST), instrument of the filter (e.g., WFC3), +and name of the filter (e.g., F275W). + +Command to add a filter to the BEAST filter library. + + .. code-block:: console + + $ python -m beast.observationmodel.phot filter_curve_file --tablename tablename + --observatory observatory --instrument instrument --filtername filtername diff --git a/docs/index.rst b/docs/index.rst index 92002230..2d1a7658 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -33,12 +33,13 @@ Basics: Photometry files Output files -Detals: +Details: .. toctree:: :maxdepth: 1 Graphical Models + Appending additional filters Stellar/Extinction Priors Generating AST inputs Simulating observations