Giter Site home page Giter Site logo

cherenkov-plenoscope / spectral_energy_distribution_units Goto Github PK

View Code? Open in Web Editor NEW
0.0 4.0 0.0 276 KB

convert units between spectral-energy-distributions in astronomy

License: MIT License

Python 100.00%
astronomy units spectral-energy-distribution particle-physics physics units-converter

spectral_energy_distribution_units's Introduction

Converting Spectral-Energy-Distributions (SEDs)

TestStatus PyPiStatus BlackStyle BlackPackStyle MITLicenseBadge

In Astronomy, SEDs can have different styles. The style effects the units and sometimes multiplies the y -axis with a power-law depending on the x -axis. But to compare findings we have to transform to a single style. This function helps you to transform between sed-styles. Here are example sed-styles A , B , C , and D showing the differential flux of Crab, and the integral sensitivity of Fermi-LAT.

A B
ImgSedFermi

ImgSedMy

A = {
    "x_energy_in_eV": 1e6,
    "y_inverse_energy_in_eV": 624150907446.0763,  # one erg
    "y_inverse_area_in_m2": 1e-4,
    "y_inverse_time_in_s": 1.0,
    "y_scale_energy_in_eV": 624150907446.0763,  # one erg
    "y_scale_energy_power": 2.0,
}

B = {
    "x_energy_in_eV": 1e9,
    "y_inverse_energy_in_eV": 1e9,
    "y_inverse_area_in_m2": 1.0,
    "y_inverse_time_in_s": 1.0,
    "y_scale_energy_in_eV": 1e9,
    "y_scale_energy_power": 0.0,
}
C D
ImgSedCosmic ImgSedCrab
C = {
    "x_energy_in_eV": 1,
    "y_inverse_energy_in_eV": 1,
    "y_inverse_area_in_m2": 1,
    "y_inverse_time_in_s": 1.0,
    "y_scale_energy_in_eV": 1,
    "y_scale_energy_power": 2.7,
}

D = {
    "x_energy_in_eV": 1e9,
    "y_inverse_energy_in_eV": 1e12,
    "y_inverse_area_in_m2": 1e-4,
    "y_inverse_time_in_s": 1.0,
    "y_scale_energy_in_eV": 1e12,
    "y_scale_energy_power": 2.0,
}

Function

Transform the numeric values in the arrays x -axis, and y -axis from style A to B.

import spectral_energy_distribution_units as sed
x_B, y_B = sed.convert_units_with_style(x=x_A, y=y_A, input_style=A, target_style=B)

Find also a function for the style-dictionaries A and B being unpacked:

x_B, y_B = sed.convert_units(x=x_A, y=y_A, x_energy_in_eV=... )

Install

pip install spectral_energy_distribution_units

Example

See unit-tests ./spectral_energy_distribution_units/tests/test_convert.py to reproduce the upper figures A , B , C , and D.

spectral_energy_distribution_units's People

Contributors

relleums avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.