Giter Site home page Giter Site logo

baysar's Introduction

Bayesian Spectral Analysis Routine

GitHub Action PyTests GitHub Action Linting Python Version GitHub license Code style: black Imports: isort GitHub issues open GitHub issues closed GitHub PR closed

Bayesian Spectral Analysis Routine (BaySAR) is an agnostic spectral fitting routine that takes descriptions of the plasma elemental composition, the electron density and temperature profile functions and spectrometer calibration to build bespoke spectral fitting posterior functions that when evaluated infers emission weighted plasma quantities as well as line of sight plasma profiles.

================= TO UPDATE START =================

This repository provides a template structure a software development project with some python functionality that is generally usefully (demonstrated in scripts/main.py). This includes:

  • Folder structure
  • Python script template (scripts/main.py)
  • PyTest example (tests/test_main.py)
  • GitHub Actions example (.github/workflows/pytest.yml)

As well as tracking information in .gitignore and python dependencies requirements.txt.

================= TO UPDATE END =================

Requesting changes: Raise an issue on the GitHub repository page and describes the error or the desired functionality, ideally with test data that can be used to make tutorials and unit tests.

Getting Started (Build, Test, and Run)

This example repo has been written in Python 3.9 and the dependencies are listed in requirements.txt. The script setup_project.sh will build the conda environment, install dependencies, and create the input/output folders and the configuration file. The actions the of setup_project.sh are:

  1. Create virtual python environment: conda create -n baysar python=3.9 --yes
  2. Install the dependencies: pip install -r requirements.txt
  3. Setting up the repo directories: mkdir input, output
  4. Create config.JSON for the user (copy from metadata): cp metadata/config.json config.json
  5. Test repo setup: PYTHONPATH=. pytest

Now the repository is locally set up you can run scripts/main.py which is a template for scripts and modules. To run from the console run PYTHONPATH=. python scripts/main.py, within the virtual environment (conda activate baysar).

How to Contribute

The following steps describe how to add new functionality to the repo:

  1. Raise an issue in this report that describes the functionality you want to add,
  2. branch from dev with the name convention feature\<descriptive-branch-name>
  3. Add code to feature\<descriptive-branch-name>
  4. Create a (draft) pull request with dev as the target (link the PR is the corresponding issue)

In the review the scripts will be reviewed against the coding standards below, passing unit tests that verify the functionality, and updated documentation and tutorials. Assistance can be provided if you are unfamiliar with implementing some of these standards.

Coding Standards

As the code should be easy if not trivial for others to reuse blind there are a series of standards that example scripts need to meet:

  • Descriptive programming style - As in variable, function, and class names should describe what they are/do.
  • Type hinting - All declared variables should have the types declared alongside it.
  • Well commented - The example should be understandable from the comments with only brief references to the code.
  • Doc string - Comment blocks at the beginning of functions and class methods that describes what the function/method does and lists the inputs, outputs, and exceptions that could be raised. This is important for the documentation of the repository.
  • An example of using the function - This will be used for automated testing to ensure functionality is maintained with changes in the repo and to write the tutorial in the document.

isort and black are used to aid code format standardisation. This can be done from the comand line using:

python -m black .
python -m isort .

The configuration for isort and black are in pyproject.toml.

Testing

Unit tests should be written to verify that the examples meet their objectives.
GitHub Actions are used to automate the running of the unit tests as a condition for merging into the main and dev branch.

baysar's People

Contributors

dgahle avatar

Stargazers

 avatar  avatar

Watchers

 avatar

baysar's Issues

netau Ionisation Balance

Implementation of ionisation balance with a tau is currently a scalar for SCD not the factor - (1 / ne*tau). The latter needs to be added for consistency.

Main update and tidy

Changes:

  • Make main the default branch
  • Merge in branches that are stale/completed tasks
  • Tag/release thesis branch

Optional log to file

Make saving the logger to file optional through a variable in config.json and get that to be read in logger.py and all other get_logger calls to use the default value set by the config to avoid conflict.

Migrate OpenADAS

Move OpenADAS functionality to its own repo OpenADAS repo and integrate that into BaySAR.

(This probably needs moving into it's own milestone and making checklist a group of issues)

Todo list:

  • Report OpenADAS and gcr modules into a single one
  • Format OpenADAS with a doc README.md
  • Get support for moving OpenADAS into it's own repo and add to PyPI
  • Move OpenADAS to it's own repo
  • Add OpenADAS to PyPI
  • Update baysar dependencies to run in a pip install of OpenADAS

Hamlitonian Sampling for Balmer Lines

Update BaySAR to be compatible with inference.mcmc.HamiltonianChain to resolve the effective sample size in demo/balmer_series.py` flatlining at about 7.

Useful links:

Task list

  • Write out the mathematics
  • Plan out the objects that require a gradient class method
  • Update this list with the above and cross out as going along
  • Add unit tests to verify functionality
  • Update demo/balmer_series.py with the HamiltonianChain

Remove tulasa

This contains useful supplementary functions and scripts but should not be in baysar repo.

Fix demo

Demo in very depricated and needs to be refactored

Scripts to fix:

  • demo/balmer_series.py
  • #20

Unittest data solution

Where to store unittest data that is open and easily accessible? Probably not in the repo.

OpenADAS Cache

API calls to the Open ADAS website should be cached to minimise URL requests. Ionisation balance output should be cached when they are evaluating the entire adf11 grids.

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.