Skip to main content

Dfisher_2022A Documentation

This project is being developed in the course of delivering the DFisher_2022A ADACS Merit Allocation Program project.

Installation

Pre-requirement:

  • python >=3.8 <3.10
  • HDF5 >= 1.8.4 (>=1.8.15 is strongly recommended)

Latest PyPI release

$ pip install dfisher_2022a

Common troubleshooting: If installation fails, try to upgrade pip by running pip install --upgrade pip first.

Latest dev-version on GitHub

$ pip install git+https://github.com/ADACS-Australia/dfisher_2022a.git#egg=dfisher_2022a

NOTICE: In the dev-version, a faster version of lmfit (light-lmfit-py) is used. This version provides a fitting method, "fast_leastsq" in addition to other fitting methods available in lmfit(1.0.3). This method can be 2x faster than leastsq. Check dev notes for more details.

Getting Started

Import the package
>>> import dfisher_2022a

Read in data cube

>>> cube = dfisher_2022a.ReadCubeFile("single_gaussian_muse_size.fits").cube

If a separate variance file is provide:

>>> cube = dfisher_2022a.ReadCubeFile("single_gaussian_muse_size.fits", "muse_var.fits").cube

Prepare data for fitting

>>> p = dfisher_2022a.ProcessedCube(cube, z=0.009, snr_threshold=5.)
1. De-redshift the cube
>>> p.de_redshift()
2. Select fitting region for a given line
>>> p.select_region("Halpha", left=20, right=20)

Keywords left and right set the wavelength cuts around the given line on both sides, e.g. the selected region is [line-left, line+right]. If this region exceeds the cube wavelength range, a nearest value within the cube will be used instead.

3. Filter the cube by SNR threshold
>>> p.get_snrmap()

Select fitting model

>>> model = dfisher_2022a.Lm_Const_1GaussModel

A single Gaussian model is available within this package.

Fit the cube

>>> cfl = dfisher_2022a.CubeFitterLM(data=p.data, weight=p.weight, x=p.x, model=model, method='leastsq') # accept lmfit.Model.fit kwargs
>>> cfl.fit_cube()

Additional keyword arguments for lmfit.Model.fit can be passed to the class object as well.

Save output

>>> out = dfisher_2022a.ResultLM()
>>> out.get_output(p) # get attributes from ProcessedCube object
>>> out.get_output(cfl)
>>> out.save()

An out directory will be generated in the current directory.

Read output

In the .out folder:

result.h5
fitdata/

where result.h5 stores the fitting result, and fitdata/ contains processed data used for fitting.

To read result.h5 file:

>>> import pandas as pd
>>> store = pd.HDFStore("result.h5")
>>> store.keys()
['/Halpha_Const_1GaussModel']
>>> df = store.get("Halpha_Const_1GaussModel")

Check available lines

>>> dfisher_2022a.EmissionLines
{'Halpha': 6562.819, 'Hb4861': 4861.333, 'Hdelta': 4101.742, ...

The line information is included in emission_lines.py. Users can customize this file (e.g. adding more lines or updating the wavelength) before importing this package.

A wrapped approach

A wrapper function encapsulating steps 1-6 is available:

>>> from dfisher_2022a import fit_lm
>>> model = dfisher_2022a.Lm_Const_1GaussModel
>>> fit_lm(cubefile="single_gaussian_muse_size.fits", line="Halpha", model=model, z=0.009, left=20, right=20, snr_threshold=5.)

Use the faster version of lmfit

If dev-version of this package is installed, which uses a faster version of lmfit as dependency, a faster fitting method is also available, by using method="fast_leastsq"and adding an argument fast=True

>>> cfl = dfisher_2022a.CubeFitterLM(data=p.data, weight=p.weight, x=p.x, model=model, method='fast_leastsq', fast=True) # accept lmfit.Model.fit kwargs
>>> cfl.fit_cube()

In the wrapper function:

>>> fit_lm(cubefile="single_gaussian_muse_size.fits", line="Halpha", model=model, z=0.009, left=20, right=20, snr_threshold=5., method="fast_leastsq", fast=True)

Create custom model

Users can create their own models following the descriptions provided by lmfit. To use fast_leastsq method in the dev version, eval_fast needs to be written as a method of the model. See dev notes of light-lmfit-py for more details.

Release files for dfisher-2022a 0.1.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dfisher-2022a 0.1.28
File Size Uploaded
dfisher_2022a-0.1.28.tar.gz 33.5 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dfisher-2022a 0.1.28
File Interpreter ABI Platform
dfisher_2022a-0.1.28-py3-none-any.whl Python 3 none any Details

Total release size: 67.0 MB

Release files / dfisher_2022a-0.1.28.tar.gz

Download URL dfisher_2022a-0.1.28.tar.gz
Size 33.5 MB
Tags Source
SHA-256 checksum
How to use checksums
cbcf6d3eafdc6b2e04fd8543c76e98d94e740982e4302eb9919c8f9f35d52de4
BLAKE2b-256 checksum
How to use checksums
834f4e9461e0de49fd3bc6ae01ed40b6eb0f37cee6817c05abd8744f07ca76c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.6 Linux/5.15.0-1014-azure

Release files / dfisher_2022a-0.1.28-py3-none-any.whl

Download URL dfisher_2022a-0.1.28-py3-none-any.whl
Size 33.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
ce62518cb58d578352602a13520bce0eb6357e59f7203ae875afa910f35abbef
BLAKE2b-256 checksum
How to use checksums
94d1da2ddacf50512657c7c4a87cf0c3e1a22f0fb757fa5159f6d9bebf5c03ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.6 Linux/5.15.0-1014-azure

Release history Release notifications | RSS feed

This release

0.1.28 This release

2 release files

0.1.26

2 release files

0.1.22

2 release files

0.1.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page