Skip to content

Commit

Permalink
adds docs, reformat with ruff, set up package
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbhughes committed Feb 25, 2024
1 parent 2b2ebeb commit d77f2b1
Show file tree
Hide file tree
Showing 33 changed files with 614 additions and 1,174 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: CI

on:
push:
pull_request:
schedule:
- cron: '0 8 * * *'

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .[test]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install .
python setup.py pytest --addopts "--cov ."
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v4
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# fail_ci_if_error: true
# verbose: true
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ cython_debug/

# overlappogram data
data/
output/
output/
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.5"
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort
entry: isort
require_serial: true
language: python
types:
- python

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
exclude: ".*(.fits|.fts|.fit|.txt|.pro|.asdf)"
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
exclude: ".*(.fits|.fts|.fit|.txt|.pro|.asdf|.bib|tca.*)"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.txt|.bib|.asdf|tca.*)"

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
Empty file added CHANGELOG.md
Empty file.
51 changes: 18 additions & 33 deletions ECCCO_multiion_inversion.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 9 08:52:51 2021
@author: dbeabout
"""
from magixs_data_products import MaGIXSDataProducts
from overlappogram.create_gnt_image import create_gnt_image
from overlappogram.create_color_color_plot import create_color_color_plot
import os
# from overlappogram.lassolars_model import LassoLarsModel as llars_model
import time

import numpy as np
from astropy.io import fits
import os
import re
import matplotlib.pyplot as plt
from overlappogram.inversion_field_angles import Inversion
#from overlappogram.inversion_field_angles_logts_ions import Inversion
from sklearn.linear_model import ElasticNet as enet, SGDRegressor, Ridge
from sklearn.linear_model import ElasticNet as enet

from magixs_data_products import MaGIXSDataProducts
from overlappogram.elasticnet_model import ElasticNetModel as model
from overlappogram.sgd_model import SGDModel
from overlappogram.ridge_model import RidgeModel
from sklearn.linear_model import LassoLars as llars
# from overlappogram.lassolars_model import LassoLarsModel as llars_model
import time
import pandas as pd
from joblib import Parallel, delayed, parallel_backend
import warnings
from sklearn.exceptions import ConvergenceWarning
from overlappogram.inversion_field_angles import Inversion

'''def calculate_weights(data, weights, sig_read, exp_time):
# Read image
Expand Down Expand Up @@ -117,7 +107,13 @@
rhos = [.1]
for rho in rhos:
for alpha in alphas:
enet_model = enet(alpha=alpha, l1_ratio=rho, max_iter=100000,precompute=True, positive=True, fit_intercept=False, selection='cyclic')
enet_model = enet(alpha=alpha,
l1_ratio=rho,
max_iter=100000,
precompute=True,
positive=True,
fit_intercept=False,
selection='cyclic')
inv_model = model(enet_model)

# regressor = SGDRegressor(penalty='elasticnet', alpha=alpha, l1_ratio=rho, fit_intercept=False)
Expand All @@ -131,19 +127,8 @@
start = time.time()
inversion.multiprocessing_invert(inv_model, inversion_dir, output_file_prefix=basename,
#inversion.invert(inv_model, inversion_dir, output_file_prefix=basename,
output_file_postfix='x'+str(solution_fov_width)+'_'+str(rho*10)+'_'+str(alpha)+'_wpsf' ,detector_row_range=detector_row_range, score=False)
output_file_postfix='x'+str(solution_fov_width)+'_'+str(rho*10)+'_'+str(alpha)+'_wpsf' ,
detector_row_range=detector_row_range,
score=False)
end = time.time()
print("Inversion Time =", end - start)

##create spectrally pure
#### mdp = MaGIXSDataProducts()
#### dir_path=inversion_dir
# image_list = [dir_path + 'eccco_lw_forwardmodel_thermal_response_psf'+str(psf)+'pix_el_decon_em_data_cube_x'+str(solution_fov_width)+'_'+str(rho*10)+'_'+str(alpha)+'.fits]'
#### image_list = [dir_path + 'eccco_is_lw_psf'+str(psf)+'pix_el_em_data_cube_x'+str(solution_fov_width)+'_'+str(rho*10)+'_'+str(alpha)+'_wpsf.fits']
#### gnt_dir=response_dir
#### gnt_file = gnt_dir + 'master_gnt_eccco_inelectrons_cm3perspersr_with_tables.fits'

#### rsp_dep_list = np.round((np.arange(56, 68, 1) / 10.0), decimals=1)
#### mdp.create_level2_0_spectrally_pure_images(image_list, gnt_file, rsp_dep_list, dir_path)


Loading

0 comments on commit d77f2b1

Please sign in to comment.