-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates to enable the MeDDEA simulator (#1)
* update to docs with logo and putting back old docs * fix to log file name * added readthedocs docs badge and added upload to codecov.io * added data directory for easy access to init * Create spectrum.py * fixed python version for readthedocs * fix to readthedocs config * added code to simulate flare and ba133 photons * added the ability to simulate x-ray sources * added file reading tools * added ccsdspy as dependency * added ability to put photon in pixels for simulations
- Loading branch information
Showing
25 changed files
with
29,668 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,27 @@ | ||
# .readthedocs.yml | ||
# Read the Docs configuration file | ||
# Read the Docs configuration file for Sphinx projects | ||
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details | ||
|
||
# Required | ||
version: 2 | ||
|
||
# Build documentation in the docs/ directory with Sphinx | ||
sphinx: | ||
configuration: docs/conf.py | ||
# Set the OS, Python version and other tools you might need | ||
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.10" | ||
|
||
# Optionally build your docs in additional formats such as PDF and ePub | ||
formats: [] | ||
formats: | ||
- epub | ||
|
||
# Optionally set the version of Python and requirements required to build your docs | ||
# Optional but recommended, declare the Python requirements required | ||
# to build your documentation | ||
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html | ||
python: | ||
version: 3.8 | ||
install: | ||
- method: pip | ||
path: . | ||
extra_requirements: | ||
- docs | ||
- all | ||
- all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,7 @@ For more details checkout the :ref:`reference`. | |
|
||
Brief Tour <tour> | ||
data | ||
level0 | ||
spectrum | ||
customization | ||
logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.. _level0: | ||
|
||
************ | ||
Level 0 Data | ||
************ | ||
|
||
Overview | ||
======== | ||
This section document the format of the level 0 binary files. | ||
Level 0 binary files are raw telemetry or command response packets generated by the instrument. | ||
|
||
|
||
Photon Packet | ||
------------- | ||
The packet which provides individual hit data or photons for each detector. | ||
|
||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Name | Bit Size | Type | Description | | ||
+=============+===========+========+============================================================+ | ||
| HEADER WORD | 16 | UINT | value is always 65131 | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| FLAGS | 16 | UNIT | various flags, To be defined | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Packet Size | 16 | UINT | The size of the packet which can be used to determine the | | ||
| | | | number of hits included in the packet | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Time Stamp | 48 | UINT | | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Checksum | 16 | UINT | For data integrity | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Pixel data | | | This field is repeated based on the number of hits detected| | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
|
||
|
||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Pixel Data | | | | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Detector id | 16 | UINT | The detector id for the location of the hit | | ||
+-------------+-----------+--------+------------------------------------------------------------+ | ||
| Hit energy | 16 | UINT | The ADC value for the energy of the hit | | ||
+-------------+-----------+--------+------------------------------------------------------------+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
.. _spectrum,: | ||
|
||
************** | ||
Spectrum Tools | ||
************** | ||
|
||
Overview | ||
======== | ||
This section tools to simulate and analyze spectra. | ||
|
||
|
||
Simulated Data | ||
-------------- | ||
This package provides tools to simulate the data that is expected during science | ||
operations. | ||
|
||
.. plot:: | ||
|
||
A plot of the sample X class flare time series (SOL2002-07-23): | ||
|
||
>>> import numpy as np | ||
>>> import matplotlib.pyplot as plt | ||
>>> import astropy.units as u | ||
>>> import padre_meddea.calibration.spectrum | ||
>>> from padre_meddea.calibration.spectrum import get_flare_rate, flare_timeseries | ||
>>> time = np.arange(10000) * u.s | ||
>>> cts = get_flare_rate()(time) | ||
>>> data_limiter = flare_timeseries['sec_from_start'] < time.max() | ||
>>> y = flare_timeseries['xrsb'][data_limiter] / flare_timeseries['xrsb'].max() * 22421.0 | ||
>>> total_counts = cts.sum() * 4 | ||
>>> plt.plot(flare_timeseries['sec_from_start'][data_limiter], y, label='data [GOES xrbs]') | ||
>>> plt.plot(time, cts, label='Interpolated', alpha=0.5, linewidth=3.0) | ||
>>> plt.legend() | ||
>>> plt.ylabel('cts/s/detector') | ||
>>> plt.xlabel('seconds from start') | ||
>>> plt.title(f'SOL2002-07-23 {total_counts/1e6:.2f} Mcounts') | ||
|
||
.. plot:: | ||
|
||
A plot of the spectrum of our sample X class flare (SOL2002-07-23): | ||
|
||
>>> import numpy as np | ||
>>> import matplotlib.pyplot as plt | ||
>>> import astropy.units as u | ||
>>> import padre_meddea.calibration.spectrum | ||
>>> from padre_meddea.calibration.spectrum import flare_spectrum, flare_spectrum_data | ||
>>> energy = np.arange(5, 100, 1) * u.keV | ||
>>> flux = flare_spectrum(1)(energy) | ||
>>> data_limiter = flare_spectrum_data['Bin mean (keV)'] < energy.max() | ||
>>> y = flare_spectrum_data['Flux (photon/s/cm ** 2/keV)'][data_limiter] | ||
>>> plt.plot(flare_spectrum_data['Bin mean (keV)'][data_limiter], y, label='data [RHESSI]') | ||
>>> plt.plot(energy, flux, label='Interpolated', alpha=0.5, linewidth=3.0) | ||
>>> plt.legend() | ||
>>> plt.yscale('log') | ||
>>> plt.xscale('log') | ||
>>> plt.ylabel('photon/s/cm ** 2/keV') | ||
>>> plt.xlabel('energy [keV]') | ||
>>> plt.title('SOL2002-07-23') | ||
|
||
.. plot:: | ||
|
||
A plot of our Ba-133 calibration source: | ||
|
||
>>> import numpy as np | ||
>>> import matplotlib.pyplot as plt | ||
>>> import astropy.units as u | ||
>>> import padre_meddea.calibration.spectrum | ||
>>> from padre_meddea.calibration.spectrum import barium_spectrum, ba133_lines, cd_kalpha1, te_kalpha1 | ||
>>> energy = np.arange(5, 150, 0.3) * u.keV | ||
>>> flux = barium_spectrum(fwhm = 1 * u.keV)(energy) | ||
>>> plt.plot(energy, flux, label='Simulated', alpha=0.5, linewidth=3.0) | ||
>>> for i, this_line in enumerate(ba133_lines): | ||
>>> cd_escape_line = this_line['energy (eV)'] - cd_kalpha1 | ||
>>> te_escape_line = this_line['energy (eV)'] - te_kalpha1 | ||
>>> if cd_escape_line > 0 * u.eV: | ||
>>> plt.axvline(x=cd_escape_line.to('keV').value, label=f'{cd_escape_line.to("keV"):.2f} Cd escape', color='red') | ||
>>> if te_escape_line > 0 * u.eV: | ||
>>> plt.axvline(x=te_escape_line.to('keV').value, label=f'{te_escape_line.to("keV"):.2f} Te escape', color='red') | ||
>>> plt.axvline(x=this_line['energy (eV)'].to('keV').value, label=f'{this_line["energy (eV)"].to("keV"):.2f} {this_line["name"]}') | ||
>>> plt.legend(loc='center left', bbox_to_anchor=(0.60, 0.5)) | ||
>>> plt.ylabel('') | ||
>>> plt.xlabel('energy [keV]') | ||
>>> plt.title('Ba-133 Calibration source') |
Oops, something went wrong.