sccala.utillib.aux

Classes

NumpyEncoder

Extensible JSON <https://json.org> encoder for Python data structures.

Functions

calc_single_error(err_low, err_high[, mode])

Calculates single error from asymmetric errors

prior_tune(l, u)

Function to fune tune inverse gamma function

velocity_conversion(x[, rest])

Converts wavelength into velocity with relativistic

distmod_kin(z[, q0, j0])

quantile(x, q[, weights])

Compute sample quantiles with support for weighted samples.

convert_to_flux(data[, data_err])

Converts magnitude data from mag to flux

convert_to_mag(data)

Converts flux data from flux to mag

nullify_output([suppress_stdout, suppress_stderr])

split_list(in_list, chunk_size)

Splits list into chunks for parallelization

Module Contents

class sccala.utillib.aux.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)

Bases: json.JSONEncoder

Extensible JSON <https://json.org> encoder for Python data structures.

Supports the following objects and types by default:

Python

JSON

dict

object

list, tuple

array

str

string

int, float

number

True

true

False

false

None

null

To extend this to recognize other objects, subclass and implement a .default() method with another method that returns a serializable object for o if possible, otherwise it should call the superclass implementation (to raise TypeError).

default(obj)

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
sccala.utillib.aux.calc_single_error(err_low, err_high, mode='mean')

Calculates single error from asymmetric errors

sccala.utillib.aux.prior_tune(l, u)

Function to fune tune inverse gamma function parameters following the example of https://betanalpha.github.io/assets/case_studies/gaussian_processes.html#323_Informative_Prior_Model

sccala.utillib.aux.velocity_conversion(x, rest=4861)

Converts wavelength into velocity with relativistic Doppler formula

Parameters

xfloat

wavelength to convert

restfloat

restwavelength w.r.t to which to convert

Returns

velfloat

velocity in m/s

sccala.utillib.aux.distmod_kin(z, q0=-0.55, j0=1)
sccala.utillib.aux.quantile(x, q, weights=None)

Compute sample quantiles with support for weighted samples. Note —- When weights is None, this method simply calls numpy’s percentile function with the values of q multiplied by 100. Parameters ———- x : array_like[nsamples,]

The samples.

qarray_like[nquantiles,]

The list of quantiles to compute. These should all be in the range [0, 1].

weightsOptional[array_like[nsamples,]]

An optional weight corresponding to each sample. These

Returns

quantilesarray_like[nquantiles,]

The sample quantiles computed at q.

Raises

ValueError

For invalid quantiles; q not in [0, 1] or dimension mismatch between x and weights.

sccala.utillib.aux.convert_to_flux(data, data_err=None)

Converts magnitude data from mag to flux

sccala.utillib.aux.convert_to_mag(data)

Converts flux data from flux to mag

sccala.utillib.aux.nullify_output(suppress_stdout=True, suppress_stderr=True)
sccala.utillib.aux.split_list(in_list, chunk_size)

Splits list into chunks for parallelization