# astronomer
***astronomer*** processes data from CONSTELATION coupled model. CONSTELATION couples the CFD code, STAR-CCM+, and the reactor physics code, Serpent 2. So far, only CFD output processing has been implemented. Processing functions for Serpent 2 results can be found in the `serpentTools` package (https://serpent-tools.readthedocs.io/en/master/).
## Usage
Install the package from PyPI using `pip` and import into your processing script.
```
pip install constelation_astronomer
```
```python
import constelation_astronomer.astronomer as astro
```
### Classes
There is one class defined in this package. The `Data` class holds the time, data, and positions header for a given set of data and makes them easily accesible. The functions used in the package use this class.
```python
data = Data(time, data_in, positions)
```
The first argument is the time array, called by `data.t`; the second is the data values array, called by `data.d`; and the third is the positons tuple, called by `data.p`.
### Functions
There are seven (7) functions defined in the package, three of the functions are plotting functions that have different labels for the different measured parameters.
---
`csv_to_data`: takes data from csv file and stores it as a `Data` class object. The first argument is the data file, expressed as a path from where the code is running. The second argument is the positions header tuple.
```python
density_data = astro.csv_to_data(filename,positions)
```
---
`plot_density`, `plot_pressure`, and `plot_temperature`: plots the data stored in the given `Data` class object. The first argument is the `Data` class object of interest. The second argument is the filename to be used as a base for the plots. The function will append *`_plot`* to the input filename before saving.
```python
astro.plot_density(density_data, filename)
```
---
`density_to_atomdensity`: converts the input data from density in kilogram per cubic meter to atom density in atoms per barn-centimeter, specifically for helium-3. The input is a `Data` class object. The output is also a `Data` class object.
```python
atomdensity_data = astro.density_to_atomdensity(density_data)
```
---
`get_time_step_data`: retrieves data at specified time values. The first argument is the `Data` class object that the user desires specific time steps from. The second argument is an array of specified time values input by the user. The function simply retrieves the time value and data values closest to the requested time without exceeding it. For the data this package was designed for, this is not an issue because the time steps are very small.
```python
atomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)
```
---
`writeData`: writes a `Data` class object out to a *.csv* file. The first argument is the `Data` class object to be written. The second argument is the path of the output file. A suggested naming scheme is made by appending '*_step.csv*' to the file that was read in originally, as seen below.
```python
astro.writeData(atomdensity_data_step, filename+'_step.csv')
```
## Examples
The functions described above can be used in any combination the user wishes, as long as the data is stored in a `Data` object. These functions can also be used for multiple data files. Below are some examples.
This first example will read in data from *astronomer/Data/HENRI_250psi_TS_density.csv*, plot the data over time, convert the density data into atom density, find the atom density data at requested time values, then write the requested values to a *.csv* file.
```python
import constelation_astronomer.astronomer as astro
filepath = 'astronomer/Data/'
filename = 'HENRI_250psi_HeatGen_TS_density'
f = filepath+filename+'.csv'
positions = ('TS00', 'TS01', 'TS02', 'TS03', 'TS04', 'TS05')
time_step = np.array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009])
density_data = astro.data_to_density(f,positions)
astro.plot_data(density_data, filename)
atomdensity_data = astro.density_to_atomdensity(density_data)
atomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)
astro.writeData(atomdensity_data_step, filepath+filename+'_step.csv')
```
---
This next example shows what it looks like to process multiple files that are using the same headers and requested time steps.
```python
import constelation_astronomer.astronomer as astro
positions = ('TS00', 'TS01', 'TS02', 'TS03', 'TS04', 'TS05')
time_step = np.array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009])
# 250 psi Heat Gen
filepath = 'astronomer/Data/'
filename = 'HENRI_250psi_HeatGen_Dens_TS'
f = filepath+filename+'.csv'
density_data = astro.data_to_density(f,positions)
astro.plot_data(density_data, filename)
atomdensity_data = astro.density_to_atomdensity(density_data)
atomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)
astro.writeData(atomdensity_data_step, filepath+filename+'_step.csv')
# 250 psi no Heat Gen
filepath = 'astronomer/Data/'
filename = 'HENRI_250psi_noHeatGen_Dens_TS'
f = filepath+filename+'.csv'
density_data = astro.data_to_density(f,positions)
astro.plot_data(density_data, filename)
atomdensity_data = astro.density_to_atomdensity(density_data)
atomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)
astro.writeData(atomdensity_data_step, filepath+filename+'_step.csv')
```
---
Finally, this third example shows using the `get_time_step_data` and `writeData` functions for more than one `Data` object.
```python
import constelation_astronomer.astronomer as astro
filepath = 'astronomer/Data/'
filename = 'HENRI_250psi_HeatGen_TS_density'
f = filepath+filename+'.csv'
positions = ('TS00', 'TS01', 'TS02', 'TS03', 'TS04', 'TS05')
time_step = np.array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009])
density_data = astro.data_to_density(f,positions)
astro.plot_data(density_data, filename)
density_data_step = astro.get_time_step_data(density_data, time_step)
astro.writeData(density_data_step, filepath+filename+'_step.csv')
atomdensity_data = astro.density_to_atomdensity(density_data)
atomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)
astro.writeData(atomdensity_data_step, filepath+filename+'_atomdensity_step.csv')
```
Raw data
{
"_id": null,
"home_page": "https://github.com/warrenau/astronomer",
"name": "constelation-astronomer",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python,data processing,Serpent 2,STAR-CCM+",
"author": "Austin Warren",
"author_email": "warrenau@oregonstate.edu",
"download_url": "https://files.pythonhosted.org/packages/82/a0/84235a3aeaaccf22f5dfa54a7e8719612bdcc4c57df8b7091422aa6ba525/constelation_astronomer-1.1.4.tar.gz",
"platform": null,
"description": "# astronomer\r\n\r\n***astronomer*** processes data from CONSTELATION coupled model. CONSTELATION couples the CFD code, STAR-CCM+, and the reactor physics code, Serpent 2. So far, only CFD output processing has been implemented. Processing functions for Serpent 2 results can be found in the `serpentTools` package (https://serpent-tools.readthedocs.io/en/master/).\r\n\r\n## Usage\r\n\r\nInstall the package from PyPI using `pip` and import into your processing script.\r\n\r\n```\r\npip install constelation_astronomer\r\n```\r\n\r\n```python\r\nimport constelation_astronomer.astronomer as astro\r\n```\r\n\r\n### Classes\r\n\r\nThere is one class defined in this package. The `Data` class holds the time, data, and positions header for a given set of data and makes them easily accesible. The functions used in the package use this class.\r\n```python\r\ndata = Data(time, data_in, positions)\r\n```\r\nThe first argument is the time array, called by `data.t`; the second is the data values array, called by `data.d`; and the third is the positons tuple, called by `data.p`.\r\n\r\n### Functions\r\n\r\nThere are seven (7) functions defined in the package, three of the functions are plotting functions that have different labels for the different measured parameters.\r\n\r\n---\r\n\r\n`csv_to_data`: takes data from csv file and stores it as a `Data` class object. The first argument is the data file, expressed as a path from where the code is running. The second argument is the positions header tuple.\r\n```python\r\ndensity_data = astro.csv_to_data(filename,positions)\r\n```\r\n\r\n---\r\n`plot_density`, `plot_pressure`, and `plot_temperature`: plots the data stored in the given `Data` class object. The first argument is the `Data` class object of interest. The second argument is the filename to be used as a base for the plots. The function will append *`_plot`* to the input filename before saving.\r\n```python\r\nastro.plot_density(density_data, filename)\r\n```\r\n\r\n---\r\n`density_to_atomdensity`: converts the input data from density in kilogram per cubic meter to atom density in atoms per barn-centimeter, specifically for helium-3. The input is a `Data` class object. The output is also a `Data` class object.\r\n```python\r\natomdensity_data = astro.density_to_atomdensity(density_data)\r\n```\r\n\r\n---\r\n`get_time_step_data`: retrieves data at specified time values. The first argument is the `Data` class object that the user desires specific time steps from. The second argument is an array of specified time values input by the user. The function simply retrieves the time value and data values closest to the requested time without exceeding it. For the data this package was designed for, this is not an issue because the time steps are very small.\r\n```python\r\natomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)\r\n```\r\n\r\n---\r\n`writeData`: writes a `Data` class object out to a *.csv* file. The first argument is the `Data` class object to be written. The second argument is the path of the output file. A suggested naming scheme is made by appending '*_step.csv*' to the file that was read in originally, as seen below.\r\n```python\r\nastro.writeData(atomdensity_data_step, filename+'_step.csv')\r\n```\r\n\r\n\r\n## Examples\r\n\r\nThe functions described above can be used in any combination the user wishes, as long as the data is stored in a `Data` object. These functions can also be used for multiple data files. Below are some examples.\r\n\r\n\r\nThis first example will read in data from *astronomer/Data/HENRI_250psi_TS_density.csv*, plot the data over time, convert the density data into atom density, find the atom density data at requested time values, then write the requested values to a *.csv* file.\r\n```python\r\nimport constelation_astronomer.astronomer as astro\r\n\r\nfilepath = 'astronomer/Data/'\r\nfilename = 'HENRI_250psi_HeatGen_TS_density'\r\nf = filepath+filename+'.csv'\r\n\r\npositions = ('TS00', 'TS01', 'TS02', 'TS03', 'TS04', 'TS05')\r\n\r\ntime_step = np.array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009])\r\n\r\ndensity_data = astro.data_to_density(f,positions)\r\nastro.plot_data(density_data, filename)\r\natomdensity_data = astro.density_to_atomdensity(density_data)\r\natomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)\r\nastro.writeData(atomdensity_data_step, filepath+filename+'_step.csv')\r\n```\r\n\r\n---\r\nThis next example shows what it looks like to process multiple files that are using the same headers and requested time steps.\r\n```python\r\nimport constelation_astronomer.astronomer as astro\r\n\r\npositions = ('TS00', 'TS01', 'TS02', 'TS03', 'TS04', 'TS05')\r\n\r\ntime_step = np.array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009])\r\n\r\n# 250 psi Heat Gen\r\nfilepath = 'astronomer/Data/'\r\nfilename = 'HENRI_250psi_HeatGen_Dens_TS'\r\nf = filepath+filename+'.csv'\r\n\r\ndensity_data = astro.data_to_density(f,positions)\r\nastro.plot_data(density_data, filename)\r\n\r\natomdensity_data = astro.density_to_atomdensity(density_data)\r\natomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)\r\nastro.writeData(atomdensity_data_step, filepath+filename+'_step.csv')\r\n\r\n\r\n# 250 psi no Heat Gen\r\nfilepath = 'astronomer/Data/'\r\nfilename = 'HENRI_250psi_noHeatGen_Dens_TS'\r\nf = filepath+filename+'.csv'\r\n\r\ndensity_data = astro.data_to_density(f,positions)\r\nastro.plot_data(density_data, filename)\r\n\r\natomdensity_data = astro.density_to_atomdensity(density_data)\r\natomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)\r\nastro.writeData(atomdensity_data_step, filepath+filename+'_step.csv')\r\n```\r\n\r\n---\r\nFinally, this third example shows using the `get_time_step_data` and `writeData` functions for more than one `Data` object.\r\n```python\r\nimport constelation_astronomer.astronomer as astro\r\n\r\nfilepath = 'astronomer/Data/'\r\nfilename = 'HENRI_250psi_HeatGen_TS_density'\r\nf = filepath+filename+'.csv'\r\n\r\npositions = ('TS00', 'TS01', 'TS02', 'TS03', 'TS04', 'TS05')\r\n\r\ntime_step = np.array([0.001, 0.002, 0.003, 0.004, 0.005, 0.006, 0.007, 0.008, 0.009])\r\n\r\ndensity_data = astro.data_to_density(f,positions)\r\nastro.plot_data(density_data, filename)\r\ndensity_data_step = astro.get_time_step_data(density_data, time_step)\r\nastro.writeData(density_data_step, filepath+filename+'_step.csv')\r\n\r\natomdensity_data = astro.density_to_atomdensity(density_data)\r\natomdensity_data_step = astro.get_time_step_data(atomdensity_data, time_step)\r\nastro.writeData(atomdensity_data_step, filepath+filename+'_atomdensity_step.csv')\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "constelation-astronomer: results processing package for CONSTELATION coupled model",
"version": "1.1.4",
"project_urls": {
"Homepage": "https://github.com/warrenau/astronomer"
},
"split_keywords": [
"python",
"data processing",
"serpent 2",
"star-ccm+"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ed0d28536b6fc1a7df0df42e729380f5834dc7b8197ee648d7f60d702cc0daac",
"md5": "551ec5ff10beaf30bdfb94129a30f9d0",
"sha256": "08b83cf1150a538edf9d8599286b0aa863a22a822075c607d0bc5b54d2b77fd3"
},
"downloads": -1,
"filename": "constelation_astronomer-1.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "551ec5ff10beaf30bdfb94129a30f9d0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6604,
"upload_time": "2024-03-12T20:11:28",
"upload_time_iso_8601": "2024-03-12T20:11:28.652680Z",
"url": "https://files.pythonhosted.org/packages/ed/0d/28536b6fc1a7df0df42e729380f5834dc7b8197ee648d7f60d702cc0daac/constelation_astronomer-1.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "82a084235a3aeaaccf22f5dfa54a7e8719612bdcc4c57df8b7091422aa6ba525",
"md5": "9e2f88f8ccbdd3e9dd0302dafb3544d0",
"sha256": "b156aa9f0c7d2321a45c5b3e3880d24591a8c62cc1827ec12c1a904ec6a95cef"
},
"downloads": -1,
"filename": "constelation_astronomer-1.1.4.tar.gz",
"has_sig": false,
"md5_digest": "9e2f88f8ccbdd3e9dd0302dafb3544d0",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6194,
"upload_time": "2024-03-12T20:11:30",
"upload_time_iso_8601": "2024-03-12T20:11:30.653253Z",
"url": "https://files.pythonhosted.org/packages/82/a0/84235a3aeaaccf22f5dfa54a7e8719612bdcc4c57df8b7091422aa6ba525/constelation_astronomer-1.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-12 20:11:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "warrenau",
"github_project": "astronomer",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "constelation-astronomer"
}