hesmapy.writers package¶
Submodules¶
hesmapy.writers.hydro1d module¶
- hesmapy.writers.hydro1d.write_hydro1d_from_dataframe(data: DataFrame | list[DataFrame], path: str, model_names: str | list[str] = None, sources: dict | list[dict] = None, units: dict = None, overwrite: bool = False, create_path: bool = True) None ¶
Write a 1D Hydrodynamical model to a JSON file compatible with the HESMA scheme from a DataFrame.
Parameters¶
- datapd.DataFrame | list[pd.DataFrame]
DataFrame or list of DataFrames containing the hydrodynamical data.
- pathstr
Path to the JSON file.
- model_namesstr | list[str], optional
Name(s) of the model(s) to write, by default None. If None, the models will be named “model_0”, “model_1”, etc.
- overwritebool, optional
Overwrite the file if it already exists, by default False.
- create_pathbool, optional
Create the path if it does not exist, by default True.
Returns¶
None
Notes¶
The DataFrame(s) must contain the following columns: - time - density - radius Other columns are optional. Only columns compliant with the HESMA scheme will be written to the JSON file.
- hesmapy.writers.hydro1d.write_hydro1d_from_dict(data: dict | list[dict], path: str, model_names: str | list[str] = None, sources: dict | list[dict] = None, units: dict = None, overwrite: bool = False, create_path: bool = True) None ¶
Write a 1D Hydrodynamical model to a JSON file compatible with the HESMA scheme from a dict.
Parameters¶
- datadict | list[dict]
dict or list of dicts containing the hydrodynamical data.
- pathstr
Path to the JSON file.
- model_namesstr | list[str], optional
Name(s) of the model(s) to write, by default None. If None, the models will be named “model_0”, “model_1”, etc.
- overwritebool, optional
Overwrite the file if it already exists, by default False.
- create_pathbool, optional
Create the path if it does not exist, by default True.
Returns¶
None
Notes¶
The dict(s) must contain the following columns: - time - density - radius Other columns are optional. Only columns compliant with the HESMA scheme will be written to the JSON file.
- hesmapy.writers.hydro1d.write_hydro1d_from_numpy(radius: ndarray | list[ndarray], density: ndarray | list[ndarray], time: float | ndarray, path: str, pressure: ndarray | list[ndarray] = None, temperature: ndarray | list[ndarray] = None, mass: ndarray | list[ndarray] = None, velocity: ndarray | list[ndarray] = None, model_names: str | list[str] = None, sources: dict | list[dict] = None, units: dict = None, overwrite: bool = False, create_path: bool = True, **kwargs) None ¶
Write a 1D Hydrodynamical model to a JSON file compatible with the HESMA scheme from numpy arrays.
Parameters¶
- radiusnp.ndarray | list[np.ndarray]
Radius of the model cells.
- densitynp.ndarray | list[np.ndarray]
Density of the model cells.
- timefloat | np.ndarray | list[np.ndarray]
Time of the model. If a float is given, it will be used for all models. If an array is given, it must have the same length as the number of models.
- pathstr
Path to the JSON file.
- pressurenp.ndarray | list[np.ndarray], optional
Pressure of the model cells, by default None.
- temperaturenp.ndarray | list[np.ndarray], optional
Temperature of the model cells, by default None.
- massnp.ndarray | list[np.ndarray], optional
Mass of the model cells, by default None.
- velocitynp.ndarray | list[np.ndarray], optional
Velocity of the model cells, by default None.
- model_namesstr | list[str], optional
Name(s) of the model(s) to write, by default None. If None, the models will be named “model_0”, “model_1”, etc.
- overwritebool, optional
Overwrite the file if it already exists, by default False.
- create_pathbool, optional
Create the path if it does not exist, by default True.
Returns¶
None
Notes¶
Abundances can be added as keyword arguments. The keyword must match the following regular expression: r’x[a-zA-Z]{1,2}[0-9]{0,3}’.