gwadama.ioo#
Input & Output Operations
Everything related to input data retrieval and output files.
- class gwadama.ioo.CoReManager(db_path)[source]#
Bases:
objectManage easily usual tasks of Watpy’s CoRe_db instances.
Ad-hoc manager to automate and make easier usual tasks in Watpy, including metadata and strain downloads, and spatial projection.
- Attributes:
- cdbwatpy.coredb.coredb.CoRe_db
Instance of CoRe_db from which everything is managed.
- db_pathPath
Folder where is or will be stored CoRe database. Refer to ‘watpy.coredb.coredb.CoRe_db’ for more details.
- eosset
All EOS found available.
- metadataDataFrame
Metadata from all simulations in ‘cdb’ collected in a single DF.
- downloadeddict
3-Level dictionary containing the path to existing strains (saved as TXT files), their eccentricity and radius of extraction. Tree-format:
- txt_files[simkey][run] = {
‘file’: ‘path/to/file.txt’, ‘eccentricity’: ecc, ‘r_extraction’: rext
}
NOTE: ONLY KEEPS 1 RUN PER SIMULATION FOR NOW
Methods
cast_to_float(string)Cast a string to float, considering '' also a NaN.
count_runs([filters])Count total number of runs in the database.
download_mode22(simkeys[, keep_h5, ...])Download ONLY the optimum strains Rh_22.
gen_strain(skey, distance, inclination, phi)Build strain from time-domain mode 22 in mass rescaled, geom.
Find the run with the lowest eccentricity for a given simulation.
load_sim(skey)Load a previously downloaded gw simulation.
sw_Y22(i, phi)Spin-weighted spherical harmonic mode lm = 22.
filter_by
filter_multiple
show
- __init__(db_path)[source]#
Initialize the manager.
- Parameters:
- db_pathstr
Folder where is or will be stored CoRe database. Refer to ‘watpy.coredb.coredb.CoRe_db’ for more details.
- count_runs(filters=[])[source]#
Count total number of runs in the database.
- Parameters:
- filterslist of lists
Format: [[key0, value0], [key1, value1], …]
- download_mode22(simkeys, keep_h5=False, overwrite=False, prot='https', lfs=False, verbose=True)[source]#
Download ONLY the optimum strains Rh_22.
Downloads each simulation, keeps the strains with the lowest eccentricity and highest extraction point ‘r’ in a TXT file, updates the database ‘self.downloaded’, and (optional) removes the original HDF5 file from CoRe to free up space.
- Parameters:
- simkeyslist
List of simulation keys (‘db_keys’ in watpy) to download.
- keep_h5bool
If False (default) removes the HDF5 file downloaded by watpy.
- overwritebool
If False (default) and a certain simulation in ‘simkeys’ is already present in ‘self.downloaded’, skip it. Otherwise downloads everything again.
- verbosebool
If True (default), print which simulations are downloaded and which are skipped.
- prot, lfs
Refer to ‘watpy.coredb.coredb.CoRe_db.sync’.
- fields_float = ['id_mass', 'id_rest_mass', 'id_mass_ratio', 'id_ADM_mass', 'id_ADM_angularmomentum', 'id_gw_frequency_Hz', 'id_gw_frequency_Momega22', 'id_kappa2T', 'id_Lambda', 'id_eccentricity', 'id_mass_starA', 'id_rest_mass_starA', 'id_mass_starB', 'id_rest_mass_starB']#
- gen_strain(skey, distance, inclination, phi)[source]#
Build strain from time-domain mode 22 in mass rescaled, geom. units.
- get_runkey_lowest_eccentricity(skey)[source]#
Find the run with the lowest eccentricity for a given simulation.
Return the key of the run and the value of its eccentricity for which this parameter is the lowest among all runs of the ‘skey’ simulation.
If a simulation has multiple runs with the same eccentricity (typically all values set to 0 or NAN) it will pick the first run in the list.
If there are one or more runs with eccentricity = NAN, the first one will be returned.
- Parameters:
- skeystr
Key (database_key) of the simulation.
- Returns:
- run_keystr
Key of the run.
- eccfloat
Eccentricity of the run.
- header_gw_txt = 'u/M:0 Reh/M:1 Imh/M:2 Redh/M:3 Imdh/M:4 Momega:5 A/M:6 phi:7 t:8'#
- gwadama.ioo.write_nested_dict_to_hdf5(file: str, *, data: dict, metadata: dict) None[source]#
Save nested dictionary of NumPy arrays to HDF5 file with metadata.
- Parameters:
- file: str
Path to the HDF5 file.
- data: dict
Nested dictionary containing NumPy arrays.
- metadata: dict
Nested dictionary containing metadata for arrays.