Skip to content

Commit

Permalink
Merge with Juan's fork.
Browse files Browse the repository at this point in the history
  • Loading branch information
M1kol4j committed Mar 2, 2023
1 parent c3dae9e commit 615c26c
Show file tree
Hide file tree
Showing 67 changed files with 23,394 additions and 3,396 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
push:
branches:
- 'master'
tags:
- 'v*'
- '!*dev*'
- '!*pre*'
- '!*post*'
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
core:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
submodules: false
envs: |
- linux: py310
test:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
submodules: false
envs: |
- windows: py39
- macos: py38
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,15 @@ ENV/

# Rope project settings
.ropeproject

# VSCode
.vscode/
.history/

# Cython Creations
helita/io/anapyio.c
helita/sim/cstagger.c
helita/utils/radtrans.c
helita/utils/utilsfast.c

*~
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
repos:
# The warnings/errors we check for here are:
# E901 - SyntaxError or IndentationError
# E902 - IOError
# F822 - undefined name in __all__
# F823 - local variable name referenced before assignment
# Others are taken care of by autopep8
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
args:
[
"--count",
"--select",
"E901,E902,F822,F823",
]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md)$"
- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
hooks:
- id: autoflake
args:
[
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variable",
]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md)$"
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["--sp", "setup.cfg"]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md)$"
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v2.0.0
hooks:
- id: autopep8
args: ["--in-place","--max-line-length", "200"]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md)$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
exclude: ".*(.fits|.fts|.fit|.header|.txt)$"
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
args: ['--enforce-all','--maxkb=1054']
- id: end-of-file-fixer
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|.json)$|^CITATION.rst$"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"
ci:
autofix_prs: false
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2017, The Helita developers and Institute of Theoretical Astrophysics.
Copyright (c) 2017-2022, The Helita developers and Institute of Theoretical Astrophysics.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Helita

Helita is a Python library for solar physics focused on interfacing with code and projects from the [Institute of Theoretical Astrophysics](http://astro.uio.no) (ITA) and the [Rosseland Centre for Solar Physics](https://www.mn.uio.no/rocs/) (RoCS) at the [University of Oslo](https://www.uio.no). The name comes from Helios + ITA.
Helita is a Python library for solar physics focused on interfacing with code and projects from the [Institute of Theoretical Astrophysics](http://astro.uio.no) (ITA) and the [Rosseland Centre for Solar Physics](https://www.mn.uio.no/rocs/) (RoCS) at the [University of Oslo](https://www.uio.no).
The name comes from Helios + ITA.

The library is a loose collection of different scripts and classes with varying degrees of portability and usefulness.

## Documentation

For more details including installation instructions, please see the documentation at http://ita-solar.github.io/helita.
For more details including installation instructions, [please see the documentation.](http://ita-solar.github.io/helita)
8 changes: 4 additions & 4 deletions helita/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

__all__ = ["io", "obs", "sim", "utils"]

from . import io
from . import obs
from . import sim
from . import utils
#from . import io
#from . import obs
#from . import sim
#from . import utils
4 changes: 4 additions & 0 deletions helita/io/anapyio.pyx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import os

import numpy as np

cimport numpy as np
from stdlib cimport free, malloc


cdef extern from "stdlib.h":
void *memcpy(void *dst, void *src, long n)

Expand Down
2 changes: 1 addition & 1 deletion helita/io/crispex.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
set of tools to deal with crispex data
"""
import xarray
import numpy as np
import scipy.interpolate as interp
import xarray


def write_buf(intensity, outfile, wave=None, stokes=False):
Expand Down
3 changes: 2 additions & 1 deletion helita/io/lp.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""
Set of tools to read and write 'La Palma' cubes
"""
import numpy as np
import os

import numpy as np


def make_header(image):
''' Creates header for La Palma images. '''
Expand Down
2 changes: 0 additions & 2 deletions helita/io/sdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ def __init__(self, filename, verbose=False):
self.verbose = verbose
self.query(filename)


def query(self, filename, verbose=False):
''' Queries the file, returning datasets and shapes.'''
f = open(filename, 'r')
Expand All @@ -32,7 +31,6 @@ def query(self, filename, verbose=False):
self.header_data(header)
return


def header_data(self, header):
''' Breaks header string into variable informationp. '''
self.variables = {}
Expand Down
19 changes: 9 additions & 10 deletions helita/io/src/anacompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int anacrunchrun8(uint8_t *x,uint8_t *array,int slice,int nx,int ny,int limit,in
for (iy=0;iy<ny;iy++) { /* start of iy (outer) loop */
/* load the first value */
x[i++] = array[iy*nx];

/* compute and store the first differences for this line */
p = (array+nx*iy); nc=nx-1;
d=dif; yq=(int) *p++; zq=(int) *p++;
Expand Down Expand Up @@ -125,7 +125,7 @@ int anacrunchrun8(uint8_t *x,uint8_t *array,int slice,int nx,int ny,int limit,in
else { y.i=(y.i & mask)<<j; x[i]=x[i] | y.b[0];}
if (nb>1) { x[i+1]=y.b[1]; if (nb>2) x[i+2]=y.b[2]; }
}

r1=r1+slice; /* bump r1 pass the fixed part */
i=r1>>3; j=r1 & 7;
/* note that r3 is the # of bits required minus 1 */
Expand Down Expand Up @@ -174,7 +174,7 @@ int anacrunchrun8(uint8_t *x,uint8_t *array,int slice,int nx,int ny,int limit,in
/* we have to put these in a form readable by the Vax (these may be used
by fcwrite) */
if(t_endian){ // big endian
bswapi32(&(ch->tsize),1); bswapi32(&(ch->bsize),1); bswapi32(&(ch->nblocks),1);
bswapi32(&(ch->tsize),1); bswapi32(&(ch->bsize),1); bswapi32(&(ch->nblocks),1);
}
free(dif);
return i; /*return # of bytes used */
Expand Down Expand Up @@ -454,7 +454,7 @@ int anacrunchrun(uint8_t *x,int16_t *array,int slice,int nx,int ny,int limit,int
/* we have to put these in a form readable by the Vax (these may be used
by fcwrite) */
if(t_endian){ // big endian
bswapi32(&(ch->tsize),1); bswapi32(&(ch->bsize),1); bswapi32(&(ch->nblocks),1);
bswapi32(&(ch->tsize),1); bswapi32(&(ch->bsize),1); bswapi32(&(ch->nblocks),1);
}
free(dif);
return i; /*return # of bytes used */
Expand All @@ -464,7 +464,7 @@ int anacrunchrun(uint8_t *x,int16_t *array,int slice,int nx,int ny,int limit,int

int anacrunch(uint8_t *x,int16_t *array,int slice,int nx,int ny,int limit,int t_endian)
// compress 16 bit array into x (a byte array) using ny blocks each of size
// nx, bit slice size slice, returns # of bytes in x
// nx, bit slice size slice, returns # of bytes in x
{
uint8_t bits[8]={1,2,4,8,16,32,64,128};
unsigned register i,j,r1,in;
Expand All @@ -487,9 +487,9 @@ int anacrunch(uint8_t *x,int16_t *array,int slice,int nx,int ny,int limit,int t_
mask-=1; // no inline expon. in C
unsigned nb; // determine the # of bytes to transfer to 32 bit int for fixed portion
if(slice==0){
nb=0;
nb=0;
}else{
if(slice<2){
if(slice<2){
nb=1;
}else{
if(slice<10) nb=2; else nb=3;
Expand Down Expand Up @@ -602,7 +602,7 @@ int anacrunch(uint8_t *x,int16_t *array,int slice,int nx,int ny,int limit,int t_
if(t_endian){ // we have to put these in a form readable by the Vax (these may be used by fcwrite)
bswapi32(&(ch->tsize),1);
bswapi32(&(ch->bsize),1);
bswapi32(&(ch->nblocks),1);
bswapi32(&(ch->nblocks),1);
}
return i; // return # of bytes used
}
Expand Down Expand Up @@ -725,9 +725,8 @@ int anacrunch32(uint8_t *x,int32_t *array,int slice,int nx,int ny,int limit,int
/* we have to put these in a form readable by the Vax (these may be used
by fcwrite) */
if(t_endian){ // big endian
bswapi32(&(ch->tsize),1); bswapi32(&(ch->bsize),1); bswapi32(&(ch->nblocks),1);
bswapi32(&(ch->tsize),1); bswapi32(&(ch->bsize),1); bswapi32(&(ch->nblocks),1);
}
/* printf("number of big ones for this I*4 = %d\n", big); */
return i; /*return # of bytes used */
} /* end of routine */

Loading

0 comments on commit 615c26c

Please sign in to comment.