API documentation#
Eval#
- cortecs.eval.eval_polynomial.eval_polynomial(temperature, pressure, wavelength, temperatures, pressures, wavelengths, fitter_results, **kwargs)[source]#
evaluates the polynomial at a given temperature and pressure.
Inputs#
- temperature: float
temperature in K.
- pressure: float
pressure in bar.
- wavelength: float
wavelength in microns.
- temperatures: array-like
temperature grid.
- pressures: array-like
pressure grid.
- wavelengths: array-like
wavelength grid.
- fitter_results: array-like
the PCA coefficients.
- returns:
xsec_int – The cross section at the given temperature and pressure.
- rtype:
float
For evaluating the PCA fit at a given temperature, pressure, and wavelength.
- cortecs.eval.eval_pca.eval_pca(temperature, pressure, wavelength, T, P, wl, fitter_results, fit_axis='pressure', **kwargs)[source]#
Evaluates the PCA fit at a given temperature, pressure, and wavelength.
Inputs#
- temperature: float
The temperature to evaluate at.
- pressure: float
The pressure to evaluate at.
- wavelength: float
The wavelength to evaluate at.
- cortecs.eval.eval_pca.eval_pca_ind_wav(first_ind, second_ind, vectors, pca_coeffs)[source]#
Evaluates the PCA fit at a given temperature and pressure.
Unfortunately, not all GPUs will support a simpler dot product, I believe, Also, we cannot loop over n_components explicitly because JAX functions require static loop lengths.
Inputs#
- first_ind: int
The index of the first axis quantity (default temperature) to evaluate at.
- second_ind: int
The index of the second axis quantity (default pressure) to evaluate at.
- vectors: array
The PCA vectors.
- pca_coeffs: array
The PCA coefficients.
- n_components: int
The number of PCA components used in the fitting
This file holds the classes for evaluating opacity data as trained by a neural network.
maybe call all of these eval_poly.py, eval_neural_net.py, etc.?
author: @arjunsavel
- cortecs.eval.eval_neural_net.eval_neural_net(T, P, temperatures=None, pressures=None, wavelengths=None, n_layers=None, weights=None, biases=None, **kwargs)[source]#
evaluates the neural network at a given temperature and pressure.
Inputs#
- T: float
The temperature to evaluate at.
- P: float
The pressure to evaluate at.
- n_layers: int
The number of layers in the neural network.
- weights: list
The weights of the neural network.
- biases: list
The biases of the neural network.
- cortecs.eval.eval_neural_net.feed_forward(x, n_layers, weights, biases)[source]#
feed forward neural network. this is a function that takes in the input, weights, and biases and returns the output.
Inputs#
- x: array-like
the input to the neural network.
- n_layers: int
the number of layers in the neural network.
- weights: list
the weights of the neural network.
biases: list
- cortecs.eval.eval_neural_net.feed_forward_equal_layer_sizes(x, n_layers, weights, biases)[source]#
feed forward neural network. this is a function that takes in the input, weights, and biases and returns the output.
This function only works if all layers have the same size.
Inputs#
- x: array-like
the input to the neural network.
- n_layers: int
the number of layers in the neural network.
- weights: list
the weights of the neural network.
biases: list
Fit#
The high-level API for fitting. Requires the Opac object.
- class cortecs.fit.fit.Fitter(opac, method='pca', **fitter_kwargs)[source]#
Bases:
object
fits the opacity data to a neural network.
todo: fit CIA. only on one dimension, because there’s no pressure dependence.
- fit(parallel=False, verbose=1)[source]#
fits the opacity data to a neural network. loops over all wavelengths. Can loop over a list of species? …should be parallelized!
Inputs#
- parallel: bool
whether to parallelize the fitting.
- fit_serial(verbose=0)[source]#
fits the opacity data with a given method. Serial. :return: todo: keep in mind that the PCA method is not actually independent of wavelength.
- method_dict = {'neural_net': <function fit_neural_net>, 'pca': <function fit_pca>, 'polynomial': <function fit_polynomial>}#
- prep_method_dict = {'neural_net': <function prep_neural_net>, 'pca': <function prep_pca>, 'polynomial': <function prep_polynomial>}#
- save_method_dict = {'neural_net': <function save_neural_net>, 'pca': <function save_pca>, 'polynomial': <function save_polynomial>}#
Module for fitting polynomial functions in temperature and pressure to opacity functions.
- cortecs.fit.fit_polynomial.fit_polynomial(Z, P, T, prep_res, plot=False)[source]#
fits a polynomial to the opacity data.
Inputs#
- Z:
(n_temp x n_pres) it’s an array.
- P:
pressure grid
- T:
temperature grid
- prep_res:
(n_temp x n_pres) PCA components
- plot:
(bool) whether to plot the fit.
- savename:
(str) if not None, the PCA components will be saved to this filename.
- rtype:
coeff: (nc x pixels) PCA coefficients
- cortecs.fit.fit_polynomial.save_polynomial(savename, coeff)[source]#
Saves the polynomial coefficients to a file.
Inputs#
- savename:
(str) if not None, the PCA components will be saved to this filename.
- coeff:
(nc x ntemp) PCA coefficients
Module for performing PCA regression on opacity functions.
- cortecs.fit.fit_pca.do_pca(cube, nc=3)[source]#
Does all the PCA steps. right now for a single spectrum.
Inputs#
- cube:
(ntemperature x npressure) array being fit with PCA. Generally, this is the opacity data at a single
wavelength as a function of temperature and pressure. :nc: (int) number of PCA components to keep. Increasing the number of components can make the reconstruction of opacity data more accurate, but it can also lead to overfitting and make the model size larger (i.e., decrease the compression factor).
- cortecs.fit.fit_pca.do_svd(standardized_cube, nc, nx)[source]#
Does the SVD (singular value decomposition) on the standardized cube.
Inputs#
- standardized_cube:
(ntemperature x npressure) standardized (mean-substracted, standard deviation-divided) array for PCA.
- nc:
(int) number of PCA components to keep in the reconstruction. Increasing the number of components can make the reconstruction
of opacity data more accurate, but it can also lead to overfitting and make the model size larger (i.e., decrease the compression factor).
- cortecs.fit.fit_pca.fit_mlr(cube, X)[source]#
todo: check array shapes. Fits the MLR (multiple linear regression) to the input cube with the PCA outputs and normalizes accordingly.
Inputs#
- cube:
(ntemp x npressure) array being fit with PCA. Generally, this is the opacity data at a single
wavelength as a function of temperature and pressure. :X: (npressure x ncomponents) PCA components. these are set by functions such as do_pca.
- returns:
beta: (ncomponents x ntemp) PCA coefficients. These are the coefficients that are used to reconstruct the
opacity data at a later stage (e.g., within an atmospheric forward model). They represent the “compressed” opacity.
- cortecs.fit.fit_pca.fit_pca(cross_section, P, T, prep_res, fit_axis='pressure', **kwargs)[source]#
Fits the PCA to the opacity data.
Inputs#
- cross_section:
(ntemp x npressure) the array of cross-sections being fit.
- P:
pressure grid
- T:
temperature grid
- xMat:
(npres x nc) PCA components
- rtype:
beta: (nc x pixels) PCA coefficients
- cortecs.fit.fit_pca.move_cross_section_axis(cross_section, fit_axis, dim=2)[source]#
todo: add docstring :param cross_section: :param fit_axis: :return:
- cortecs.fit.fit_pca.prep_pca(cross_section, wav_ind=-1, nc=2, force_fit_constant=False, fit_axis='pressure')[source]#
Prepares the opacity data for PCA. That is, it calculates the PCA components to be fit along the entire dataset by fitting the PCA to a single wavelength.
todo: perform type checking for inputs.
Inputs#
- cross_section:
(ntemp x npressure x nwavelength) the array of cross-sections being fit.
- wav_ind:
(int) index of wavelength to fit. Ideally, this should be fit to a wavelength that has somewhat
representative temperature–pressure structure to the opacity function. If there is no temperature or wavelength dependence at this wavelength index but strong dependence elsewhere, for instance, the opacity function will be poorly reconstructed. :nc: (int) number of PCA components to keep. Increasing the number of components can make the reconstruction of opacity data more accurate, but it can also lead to overfitting and make the model size larger (i.e., decrease the compression factor). :force_fit_constant: (bool) if True, will allow the PCA to fit an opacity function without temperature and pressure dependence. This usually isn’t recommended, if these PCA vectors are to e used to fit other wavelengths that do have temperature and pressure dependence. :fit_axis: (str) the axis to fit against. determines the shape of the final vectors and components. if “best”, chooses the largest axis. otherwise, can select “temperature” or “pressure”.
- rtype:
xMat: (n_exp x nc) PCA components
- cortecs.fit.fit_pca.save_pca(savename, fit_results)[source]#
Saves the PCA components and coefficients to files
Inputs#
- savename:
(str) if not None, the PCA components will be saved to this filename.
- fit_results:
contains the PCA coeefficients and vectors.
- cortecs.fit.fit_pca.standardize_cube(input_array)[source]#
Prepares an array for PCA.
Inputs#
- input_array:
(ntemperature x npressure) array for PCA.
- rtype:
standardized_cube: (ntemperature x npressure) standardized (mean-substracted, standard deviation-divided) array for PCA.
Trains a neural network to fit the opacity data.
- cortecs.fit.fit_neural_net.fit_neural_net(cross_section, P, T, wl, n_layers=3, n_neurons=8, activation='sigmoid', learn_rate=0.04, loss='mean_squared_error', epochs=2000, verbose=0, sequential_model=None, plot=False)[source]#
trains a neural network to fit the opacity data.
Inputs#
- cross_section:
(ntemp x npressure) the array of cross-sections being fit.
- P:
(array) pressure grid corresponding to the cross-sections.
- T:
(array) temperature grid corresponding to the cross-sections.
- wl:
(array) wavelength grid corresponding to the cross-sections.
- n_layers:
(int) number of layers in the neural network. Increasing this number increases the flexibility of the model, but it also increases the number of parameters that need to be fit — and hence the model size and training time.
- n_neurons:
(int) number of neurons in each layer. Increasing this number increases the flexibility of the model, but it also increases the number of parameters that need to be fit — and hence the model size and training time.
- activation:
(str) activation function to use. See the keras documentation for more information: https://keras.io/api/layers/activations/
- learn_rate:
(float) learning rate for the optimizer. Increasing this number can help the model converge faster, but it can also cause the model to diverge.
- loss:
(str) loss function to use. See the keras documentation for more information: https://keras.io/api/losses/
- epochs:
(int) number of epochs to train for. Increasing this number can help the model converge better, but it primarily makes the training time longer.
- verbose:
(int) verbosity of the training.
- sequential_model:
(keras.Sequential) if not None, this is the neural network to be trained.
- plot:
(bool) whether to plot the loss.
- returns:
history: the history object from the keras fit method
neural_network: the trained neural network
todo: implement all_wl
- cortecs.fit.fit_neural_net.save_neural_net(filename, fit_results)[source]#
saves the neural network to a file.
Inputs#
- filename:
(str) filename to save the neural network to.
- fit_results:
(keras.Sequential) the neural network to save.
- rtype:
None:
- cortecs.fit.fit_neural_net.unravel_data(x, y, z=None, tileboth=False)[source]#
unravels the data into a single column. takes log the log of quantities as well.
todo: move to a utils file?
Inputs#
- x: array-like
first dimension of data.
- y: array-like
second dimension of data.
- z: array-like
third dimension of data.
Opac#
A few functions that can be used to chunk opacity files. Assumes that opacity files are in the RT code format, that each opacity file to be chunked is in its on folder, and that we are currently in that folder.
Example instructions / workflow:
>>> file = 'opacTiO.dat'
>>> chunk_wavelengths(file, wav_per_chunk=2598)
>>> filename = 'opacTiO'
>>> add_overlap(filename)
And that should work!
There’s some replicated (and likely unnecessary) code, but it hopefully shouldn’t be too confusing. Furthermore, these functions have not been subjected to robust unit testing, so they might not work right out of the box. Please let me know if that’s the case, and I’d be happy to debug :)
author: @arjunsavel
so far, only works for exo-transmit chunks. TODO: generalize for others.
- cortecs.opac.chunking.add_lams(max_lam_to_add_ind, file, next_file)[source]#
Takes the first max_lam_to_add_ind opacities from next_file and appends them to file.
- Inputs:
- max_lam_to_add_ind:
(int) number of wavelength points to add from one file to the other.
- file:
(str) (str) path to file to which wavelength points are being added.
- next_file:
(str) path to file from which wavelength points are being drawn.
- Outputs:
None
- Side effects:
Modifies file.
- cortecs.opac.chunking.add_overlap(filename, v_max=11463.5)[source]#
Adds overlap from file n+1 to file n. The last file has nothing added to it. This step is necessary for the Doppler-on version of the RT code.
*Assumes that the current directory only has files labeled ‘filename*.dat’*
- Inputs:
- filename:
(str) “base name” of the opacity chunks. e.g., ‘opacFe’, corresponding to ‘opacFe*.dat’.
- v_max:
(float, default 11463.5) maximum velocity that will be Doppler-shifted to in the RT code. Twice this value is used to calculate how much overlap to include (+ an extra 20 wavelength points, to be safe!). The default comes from Tad’s WASP-76b GCM outputs. [m/s]
- Output:
None
- Side effects:
Modifies every ‘filename*.dat’ file.
- cortecs.opac.chunking.chunk_wavelengths(file, nchunks=None, wav_per_chunk=None, adjust_wavelengths=False, loader='exotransmit')[source]#
Performs wavelength-chunking. todo: yell if the chunked results are already in the directory?
Inputs#
- file:
path to file to be chunked. e.g., ‘opacFe.dat’.
- nchunks:
(int or None) Number of chunks to use, splitting the opacity file into roughly even chunks. If None, wav_per_chunk must be specified.
- wav_per_chunk:
(int or None) Number of wavelengths per chunk. If None, nchunks must be specified.
- adjust_wavelengths:
(bool) whether or not to scale from CGS to MKS. For most situations, can be kept false.
Outputs#
None
Side effects#
Creates a number of files in same directory as file, titled file*.dat.
- cortecs.opac.chunking.get_header(file)[source]#
Gets the header of a file.
- Inputs:
- file:
(str) path to file whose header we want.
- Outputs:
header of file (string)
- cortecs.opac.chunking.write_to_file(line, file, file_suffix, numfiles=None)[source]#
Writes (appends, really) a line to a file.
- Inputs:
- line:
(str) line to write to file.
- file:
(str) base path to file to be written to. e.g., ‘opacFe’
- file_suffix:
(int) suffix to add, usually chunk number. e.g. 5
- Outputs:
None
- Side effects:
Writes a line to a file!
Functions that can be used to interpolate CIA to a higher resolution and subsequently chunk it up. Example instructions / workflow: >>> reference_file = ‘../opacFe/opacFe.dat’ >>> CIA_file = ‘opacCIA.dat’ >>> interpolate_cia(CIA_file, reference_file) >>> CIA_file = ‘opacCIA_highres.dat’ >>> ref_file_base = ‘../opacFe/opacFe’ >>> chunk_wavelengths_cia(CIA_file, ref_file_base) And that should work!
todo: generalize to PLATON CIA.
author: @arjunsavel
- cortecs.opac.interpolate_cia.add_line_string_species(line_string, species_dict, i, buffer)[source]#
Adds the species to the line string. Inputs ——
- line_string:
(str) the line string to be modified.
- species_dict:
(dict) dictionary of species to be interpolated.
- i:
(int) index of the line string.
- buffer:
(str) buffer between each species.
Outputs#
None
Side effects#
Modifies line_string in place.
- cortecs.opac.interpolate_cia.build_new_string(interped_wavelengths, interped_temps, reference_species, species_dict_interped)[source]#
Builds the new string that will be written to the new CIA file. Inputs ——
- interped_wavelengths:
(list) list of wavelengths that have been interpolated.
- interped_temps:
(list) list of temperatures that have been interpolated.
- reference_species:
(list) list of species that have been interpolated.
- buffer:
(str) buffer between each species.
Outputs#
- new_string:
(list) list of strings that will be written to the new CIA file.
Side effects#
None
- cortecs.opac.interpolate_cia.check_temp_grid(df, real_temperature_grid, cia_file)[source]#
Checks that the temperature grid of the CIA file is the same as the reference file. Inputs ——
- df:
(pd.DataFrame) dataframe with the CIA data.
- real_temperature_grid:
(np.array) temperature values for which the opacity file had been computed.
Outputs#
None
Side effects#
Raises a ValueError if the temperature grid is not the same.
- cortecs.opac.interpolate_cia.check_wav_grid(reference_opac, df)[source]#
Checks that the wavelength grid of the CIA file is the same as the reference file. Inputs ——
- reference_opac:
(Opac) Opac object with the wavelength grid of interest.
- df:
(pd.DataFrame) dataframe with the CIA data.
Outputs#
None
Side effects#
Raises a ValueError if the wavelength grid is not the same.
- cortecs.opac.interpolate_cia.chunk_wavelengths_cia(file, ref_file_base, numfiles)[source]#
Performs chunking based on the reference file’s wavelength chunking. Inputs ——-
- file:
(str) path to CIA file that should be chunked. e.g., opacCIA_highres.dat.
- ref_file_base:
(str) path base to a set of reference files that are already chunked on the desired wavelength grid. e.g., ../opacFe/opacFe
- cortecs.opac.interpolate_cia.get_wav_per_chunk(file_suffix, ref_file_base)[source]#
Grabs the number of wavelengths of a given chunk. Inputs ——
- file_suffix:
(int) number corresponding to the given chunk. e.g., 1.
- ref_file_base:
(str) path base to a set of reference files that are already chunked on the desired wavelength grid. e.g., ../opacFe/opacFe
Outputs#
- len_grid:
(int) number of wavelengths in chunk.
- cortecs.opac.interpolate_cia.initialize_species_dict(species_dict, wavelength_grid)[source]#
Initializes a dictionary of species to be interpolated. Inputs ——
- species_dict:
(dict) dictionary of species to be interpolated.
Outputs#
None
Side effects#
Modifies species_dict in place.
- cortecs.opac.interpolate_cia.interpolate_cia(cia_file, reference_file, outfile=None, loader='exotransmit', load_kwargs=None)[source]#
Interpolates a CIA file to a higher resolution, using the wavelength grid of a reference file. Note: This function assumes that the CIA file has Hels, HeHs, CH4CH4s, H2Hes, H2CH4s, H2Hs, H2H2s, and CO2CO2s.
TODO: add 2d interpolation. Inputs ——
- CIA_file:
(str) path to CIA file to be interpolated. e.g., ‘opacCIA/opacCIA.dat’
- reference_file:
(str) path to opacity file with the wavelength grid of interest. e.g., ‘opacFe/opacFe.dat’
Outputs#
None
Side effects#
Creates a file with “hires” attached to the end of CIA_file that has been interpolated to higher resolution.
- cortecs.opac.interpolate_cia.prepend_line(file_name, line)[source]#
Insert given string as a new line at the beginning of a file. Used to fix the header within the chunked CIA files.
Inputs#
- file_name:
(str) path to file to be modified.
- line:
(str) line to be inserted.
Outputs#
None
Side effects#
Modifies the file in place.
Reads opacity data from various sources.
author: @arjunsavel
- cortecs.opac.io.get_empty_species_dict(CIA_file, verbose=False)[source]#
returns a species dictioanry given a CIA file
Inputs#
- CIA_file:
(str) path to CIA file. e.g., ‘opacCIA/opacCIA.dat’
- verbose:
(bool) whether to print out the species that are likely in the file.
Outputs#
- species_dict:
(dict) dictionary of species.
- cortecs.opac.io.get_n_species(CIA_file, verbose=False)[source]#
Returns the number of species in a CIA file. Inputs ——-
- CIA_file:
(str) path to CIA file. e.g., ‘opacCIA/opacCIA.dat’
Outputs#
- n_species:
(int) number of species in the CIA file.
- class cortecs.opac.io.loader_base(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
object
loads in opacity data from various sources. To be passed on to Opac object.
todo: tutorial on how to use this?
- class cortecs.opac.io.loader_chimera(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
loader_base
loads in opacity data that are produced with the CHIMERA code.
- class cortecs.opac.io.loader_exotransmit(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
loader_base
loads in opacity data in the exo-transmit format. This format is also used by PLATON, I believe.
- get_lams_and_opacities(file)[source]#
Takes in an opacity file and returns an array of all wavelengths within the file.
Returns the opacities, as well — so that the file is only iterated through once.
- Inputs:
- file:
(str) path to opacity file.
- Outputs:
- wavelengths:
(numpy.array) individual wavelength points within the opacity file [m]
- class cortecs.opac.io.loader_exotransmit_cia(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
loader_base
loads in opacity data that are used with the PLATON code’s collision-induced absorption..
- class cortecs.opac.io.loader_helios(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
loader_base
loads in opacity data that are produced with the HELIOS ktable function.
- P_key = 'pressures'#
- T_key = 'temperatures'#
- cross_section_key = 'opacities'#
- wl_key = 'wavelengths'#
- wl_style = 'wl'#
- class cortecs.opac.io.loader_platon(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
loader_base
loads in opacity data that are used with the PLATON code.
- load(cross_sec_filename, T_filename='', P_filename='', wl_filename='')[source]#
loads in opacity data that’s built for PLATON. To be passed on to Opac object.
The temperature grid, pressure grid, and wavelength grid are saved as separate files for PLATON.
Inputs#
- filenamestr
name of file to load
- cross_sec_filenamestr
name of cross section file
- T_filenamestr
name of temperature file
- P_filenamestr
name of pressure file
- wl_filenamestr
name of wavelength file
- species_weight_dict = {'C2H2': 26.038, 'C2H4': 28.054, 'CH4': 16.04, 'CH4+': 16.04, 'CH4-': 16.04, 'CO': 28.01, 'CO2': 44.009, 'FeH': 55.845, 'H': 1.008, 'H+': 1.008, 'H-': 1.008, 'H2': 2.016, 'H2+': 2.016, 'H2-': 2.016, 'H2O': 18.015, 'H2O+': 18.015, 'H2O-': 18.015, 'H2S': 34.08, 'H3+': 3.024, 'H3-': 3.024, 'HCN': 27.026, 'He': 4.003, 'He+': 4.003, 'K': 39.098, 'NH3': 17.031, 'Na': 22.99, 'PH3': 33.997, 'TiO': 63.866, 'VO': 66.94, 'e-': 0.00054858}#
- class cortecs.opac.io.loader_platon_cia(wl_key='wno', T_key='T', P_key='P', cross_section_key='xsec', wl_style='wno', temperature_axis=0, pressure_axis=1, wavelength_axis=2)[source]#
Bases:
loader_base
loads in opacity data that are used with the PLATON code’s collision-induced absorption..
- load(cross_sec_filename, T_filename, wl_filename, species_name)[source]#
loads in opacity data that’s built for PLATON. To be passed on to Opac object.
The temperature grid, pressure grid, and wavelength grid are saved as separate files for PLATON.
Inputs#
- filenamestr
name of file to load
- cross_sec_filenamestr
name of cross section file
- T_filenamestr
name of temperature file
- wl_filenamestr
name of wavelength file
- species_nametuples
name of two colliding species. E.g., (‘H2’, ‘CH4’). todo: all at once?
- class cortecs.opac.io.writer_exotransmit_cia[source]#
Bases:
writer_base
does writing for the CIA object, takng in an opac object.
this file holds the class describing opacity data. hmm…maybe I want the loader in a different file?
author: @arjunsavel
- class cortecs.opac.opac.Opac(filename, loader='chimera', load_kwargs={})[source]#
Bases:
object
this class holds the opacity data and provides methods for evaluating the opacity at a given temperature and pressure.
Everything’s already been loaded into memory, so this is just a wrapper for the data.
todo: use the different loaders
- P = None#
- T = None#
- method_dict = {'chimera': <class 'cortecs.opac.io.loader_chimera'>, 'exotransmit': <class 'cortecs.opac.io.loader_exotransmit'>, 'helios': <class 'cortecs.opac.io.loader_helios'>, 'platon': <class 'cortecs.opac.io.loader_platon'>}#
- wl = None#
- class cortecs.opac.opac.Opac_cia(filename, loader='platon_cia', view='default')[source]#
Bases:
Opac
this class holds the opacity data and provides methods for evaluating the opacity at a given temperature and pressure.
Everything’s already been loaded into memory, so this is just a wrapper for the data.
- join_cross_section(opac)[source]#
joins another opacity’s cross-section data to this one. :param opac: :return:
- method_dict = {'exotransmit_cia': <class 'cortecs.opac.io.loader_exotransmit_cia'>, 'platon_cia': <class 'cortecs.opac.io.loader_platon_cia'>}#
Optimize#
Holds object for optimizing the fits.
- class cortecs.opt.opt.Optimizer(fitter, **optim_kwargs)[source]#
Bases:
object
for optimizing the fits.
- method_dict = {'neural_net': <function optimize_neural_net>, 'pca': <function optimize_pca>, 'polynomial': <function optimize_polynomial>}#
Performs simple optimization of neural network hyperparameters.
- cortecs.opt.optimize_neural_net.optimize_neural_net(max_size, max_evaluations, opac, min_layers=2, min_neurons=2, max_layers=3, max_neurons=13, min_learn_rate=0.01, max_learn_rate=0.1)[source]#
performs simple optimization of neural network hyperparameters.
Inputs#
- max_size: float
maximum size of file in kB.
- max_evaluations: int
maximum number of evaluations of the neural network.
Performs simple optimization of PCA hyperparameters — i.e., number of components and wavelength index for computing eigenvectors.