This file contains hidden or 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
| import numpy as np | |
| import astropy.constants as con | |
| import astropy.units as u | |
| # In the corona, the Coulomb logarithm is approximately 20. | |
| # Note: Kontar+ calls Lambda the Coulomb logarithm, although | |
| # Lambda usually refers to the plasma parameter, i.e. the argument to that logarithm. | |
| # Don't get confused by that notation. | |
| COULOMB_LOG = 20 | |
| ELECTRON_MASS_ENERGY = (con.m_e * con.c**2).to(u.keV) |
This file contains hidden or 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
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| ''' | |
| Here we show an example pileup rejection algorithm based on splitting an integral in half. | |
| The algorithm is very simple: assume a uniform pulse shape across time, | |
| and then say how much time it takes to integrate half of the pulse area. | |
| Look at the `pileup_detect` function for the implementation. | |
| W Setterberg 2025 |
This file contains hidden or 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
| import logging | |
| logging.basicConfig() | |
| logger = logging.getLogger(__name__) | |
| import asdf | |
| import astropy.units as u | |
| import astropy.constants as c | |
| import fiasco | |
| from fiasco.util.exceptions import MissingDatasetException | |
| import numpy as np |
This file contains hidden or 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
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| def area_contour_image(img: np.ndarray, quantiles: list[float], ax=None, x=None, y=None, **contour_kwds): | |
| normalized_img = (img - np.min(img)) / (np.max(img) - np.min(img)) | |
| flattened_img = normalized_img.flatten() | |
| # sort pixels: small areas first, then large areas | |
| sorted_values = np.sort(flattened_img)[::-1] |
This file contains hidden or 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
| from astropy.io import fits | |
| import astropy.table as atab | |
| import astropy.time as atime | |
| import astropy.units as u | |
| import numpy as np | |
| from stixdcpy import instrument as inst | |
| def load_stix_pixel_data_to_spectrogram(fn: str) -> dict: | |
| pdat = load_stix_pixel_data(fn) |
This file contains hidden or 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
| import astropy.units as u | |
| import numpy as np | |
| from sklearn import linear_model | |
| import typing | |
| @u.quantity_input | |
| def decompose( | |
| counts: u.ct, | |
| energy_bins: u.keV, |
This file contains hidden or 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
| import requests | |
| import parse | |
| import os | |
| import sys | |
| verbose = True | |
| def vp(*args, **kw): |
This file contains hidden or 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
| import numpy as np | |
| import numpy.typing | |
| ''' | |
| Perform a flux- (i.e. area-) conserving rebinning of a histogram, | |
| given its edges and a set of new edges. | |
| The __name__ ... section has an example using a power law. |
This file contains hidden or 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
| from datetime import datetime | |
| import functools | |
| import multiprocessing as mp | |
| import os | |
| import pathlib | |
| import sys | |
| import imageio | |
| import numpy as np | |
| import sunpy.map |