Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
ci=> actions, black style
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Oct 2, 2019
1 parent 97ab525 commit 7602f28
Show file tree
Hide file tree
Showing 29 changed files with 547 additions and 538 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[flake8]
max-line-length = 132
ignore = E203
exclude = .git,__pycache__,.eggs/,doc/,docs/,build/,dist/,archive/,src/
per-file-ignores =
__init__.py:F401
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [scivision]
ko_fi: scivision
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: ci

on:
push:
paths-ignore:
- "**/*.md"
pull_request:
paths-ignore:
- "**/*.md"

jobs:

linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- run: pip install .[tests,lint]
- run: flake8
- run: mypy .
- run: pytest -r a -v
working-directory: tests

integration:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- run: pip install .[tests]
- run: pytest -r a -v
working-directory: tests
20 changes: 10 additions & 10 deletions DascThemisFOV.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@


def main():
p = ArgumentParser(description='register/plot other camera FOV onto Themis FOV')
p.add_argument('themiscal', help='ASI calibration')
p.add_argument('dasccal', help='DASC cal', nargs=3)
p.add_argument('-o', '--ofn', help='write output plot')
p = ArgumentParser(description="register/plot other camera FOV onto Themis FOV")
p.add_argument("themiscal", help="ASI calibration")
p.add_argument("dasccal", help="DASC cal", nargs=3)
p.add_argument("-o", "--ofn", help="write output plot")
P = p.parse_args()

# %% load data
# %% load data
themis = ta.loadcal(P.themiscal)
dasc = dio.load(*P.dasccal)
# %% merge FOV
# %% merge FOV
# paint HiST field of view onto Themis
themis, dasc = taf.mergefov(themis, dasc, projalt=110e3, method='perimeter')
# %% plot joint az/el contours
tap.jointazel(themis, P.ofn, 'Themis Gakona overlaid on Poker Flat ASI')
themis, dasc = taf.mergefov(themis, dasc, projalt=110e3, method="perimeter")
# %% plot joint az/el contours
tap.jointazel(themis, P.ofn, "Themis Gakona overlaid on Poker Flat ASI")

show()


if __name__ == '__main__':
if __name__ == "__main__":
main()
61 changes: 30 additions & 31 deletions DascThemisSlice.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,57 +18,56 @@
import themisasi as ta
import themisasi.plots as tap
import dascutils.io as dio

try:
from matplotlib.pyplot import show
except ImportError:
show = None


def main():
p = ArgumentParser(description='register/plot other camera FOV onto Themis FOV')
p.add_argument('themiscal', help='ASI calibration')
p.add_argument('dasccal', help='DASC cal', nargs=3)
p.add_argument('-o', '--ofn', help='write output plot')
p.add_argument('-v', '--verbose', action='store_true')
p = ArgumentParser(description="register/plot other camera FOV onto Themis FOV")
p.add_argument("themiscal", help="ASI calibration")
p.add_argument("dasccal", help="DASC cal", nargs=3)
p.add_argument("-o", "--ofn", help="write output plot")
p.add_argument("-v", "--verbose", action="store_true")
P = p.parse_args()

# %% load az/el data
# %% load az/el data
themis = ta.loadcal(P.themiscal)
if themis.site == 'gako':
themis.attrs['Baz'] = 21.028
themis.attrs['Bel'] = 75.816
themis.attrs['Bepoch'] = '2010-01-01'
themis.attrs['verbose'] = False
themis.attrs['srpts'] = np.logspace(5, 6.9, 40)
themis['cutcol'] = np.arange(50, themis.x.size - 75, 1, dtype=int)
if themis.site == "gako":
themis.attrs["Baz"] = 21.028
themis.attrs["Bel"] = 75.816
themis.attrs["Bepoch"] = "2010-01-01"
themis.attrs["verbose"] = False
themis.attrs["srpts"] = np.logspace(5, 6.9, 40)
themis["cutcol"] = np.arange(50, themis.x.size - 75, 1, dtype=int)

dasc = dio.load(*P.dasccal)
if 'lat' not in dasc.attrs:
dasc.attrs['lat'] = 65.126
dasc.attrs['lon'] = -147.479
dasc.attrs['alt_m'] = 200.
dasc.attrs['Baz'] = 21.145 # Baz = declination
dasc.attrs['Bel'] = 77.464 # Bel = inclination
dasc.attrs['Bepoch'] = '2010-01-01'
dasc.attrs['verbose'] = False
if "lat" not in dasc.attrs:
dasc.attrs["lat"] = 65.126
dasc.attrs["lon"] = -147.479
dasc.attrs["alt_m"] = 200.0
dasc.attrs["Baz"] = 21.145 # Baz = declination
dasc.attrs["Bel"] = 77.464 # Bel = inclination
dasc.attrs["Bepoch"] = "2010-01-01"
dasc.attrs["verbose"] = False
# np.linspace(10**4.6,10**6.8,40) #np.logspace(4.6, 6.4, 40)
dasc.attrs['srpts'] = np.logspace(4.6, 7.5, 40)
dasc['cutcol'] = np.arange(75, dasc.x.size - 100, 1, dtype=int)
# %% extract common 2-D slice (plane)
dasc.attrs["srpts"] = np.logspace(4.6, 7.5, 40)
dasc["cutcol"] = np.arange(75, dasc.x.size - 100, 1, dtype=int)
# %% extract common 2-D slice (plane)
# paint HiST field of view onto Themis
themis, dasc = taf.mergefov(themis, dasc, projalt=110e3, method='MZslice')
themis, dasc = taf.mergefov(themis, dasc, projalt=110e3, method="MZslice")
themis = taf.line2plane(themis)
dasc = taf.line2plane(dasc)
if show is None:
return
# %% plot slice pixel mask
tap.jointazel(
themis, P.ofn, 'Themis Gakona slice toward DASC and magnetic zenith')
tap.jointazel(
dasc, P.ofn, 'DASC Poker Flat slice toward Themis Gakona and magnetic zenith')
# %% plot slice pixel mask
tap.jointazel(themis, P.ofn, "Themis Gakona slice toward DASC and magnetic zenith")
tap.jointazel(dasc, P.ofn, "DASC Poker Flat slice toward Themis Gakona and magnetic zenith")

show()


if __name__ == '__main__':
if __name__ == "__main__":
main()
20 changes: 10 additions & 10 deletions DownloadThemis.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
import themisasi.web as tweb
from argparse import ArgumentParser

VIDEO_BASE = 'http://themis.ssl.berkeley.edu/data/themis/thg/l1/asi/'
CAL_BASE = 'http://themis.ssl.berkeley.edu/data/themis/thg/l2/asi/cal/'
VIDEO_BASE = "http://themis.ssl.berkeley.edu/data/themis/thg/l1/asi/"
CAL_BASE = "http://themis.ssl.berkeley.edu/data/themis/thg/l2/asi/cal/"


def main():
p = ArgumentParser()
p.add_argument('startend', help='start/end times UTC e.g. 2012-11-03T06:23 2012-11-03T06:24', nargs='+')
p.add_argument('odir', help='directory to write downloaded CDF to')
p.add_argument('-s', '--site', help='fykn gako etc.', nargs='+')
p.add_argument('-overwrite', help='overwrite existing files', action='store_true')
p.add_argument('-vh', help='Stem of URL for Video data', default=VIDEO_BASE)
p.add_argument('-ch', help='Stem of URL for calibration data', default=CAL_BASE)
p.add_argument("startend", help="start/end times UTC e.g. 2012-11-03T06:23 2012-11-03T06:24", nargs="+")
p.add_argument("odir", help="directory to write downloaded CDF to")
p.add_argument("-s", "--site", help="fykn gako etc.", nargs="+")
p.add_argument("-overwrite", help="overwrite existing files", action="store_true")
p.add_argument("-vh", help="Stem of URL for Video data", default=VIDEO_BASE)
p.add_argument("-ch", help="Stem of URL for calibration data", default=CAL_BASE)

P = p.parse_args()

urls = {'video_stem': P.vh, 'cal_stem': P.ch}
urls = {"video_stem": P.vh, "cal_stem": P.ch}

tweb.download(P.startend, P.site, P.odir, P.overwrite, urls)


if __name__ == '__main__':
if __name__ == "__main__":
main()
8 changes: 4 additions & 4 deletions Examples/Projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import themisasi.projections as tap


datadir = Path('~/data/2016-11-29').expanduser()
datadir = Path("~/data/2016-11-29").expanduser()

time_query = '2016-11-29T12'
time_query = "2016-11-29T12"

ta.download(time_query, 'mcgr', datadir)
ta.download(time_query, "mcgr", datadir)

dat = ta.load(datadir, site='mcgr', treq=time_query)
dat = ta.load(datadir, site="mcgr", treq=time_query)

tap.asi_projection(dat, 110e3)
22 changes: 12 additions & 10 deletions Examples/Themis2008.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
import themisasi.plots as tap
from pathlib import Path
from matplotlib.pyplot import show

try:
import seaborn as sns
sns.set_context('talk')

sns.set_context("talk")
except ImportError:
pass

# %% user parameters
datadir = Path('~/data/themis').expanduser()
site = 'gako'
asifn = ('thg_l1_asf_gako_2008032607_v01.cdf',
'thg_l1_asf_gako_2008032608_v01.cdf')
treq = [('2008-03-26T07:34', '2008-03-26T07:38'), # Slide 9
('2008-03-26T07:46', '2008-03-26T07:50'), # Slide 15
('2008-03-26T08:16', '2008-03-26T08:20'), # Slide 30
]
datadir = Path("~/data/themis").expanduser()
site = "gako"
asifn = ("thg_l1_asf_gako_2008032607_v01.cdf", "thg_l1_asf_gako_2008032608_v01.cdf")
treq = [
("2008-03-26T07:34", "2008-03-26T07:38"), # Slide 9
("2008-03-26T07:46", "2008-03-26T07:50"), # Slide 15
("2008-03-26T08:16", "2008-03-26T08:20"), # Slide 30
]
odir = None

asical = datadir / 'themis_skymap_gako_20070401.sav'
asical = datadir / "themis_skymap_gako_20070401.sav"
# %% load data, with calibration az/el
data0 = ta.load(datadir / asifn[0], treq=treq[0], calfn=asical)
data1 = ta.load(datadir / asifn[0], treq=treq[1], calfn=asical)
Expand Down
53 changes: 26 additions & 27 deletions Examples/ThemisHistApr14T854.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,52 @@
from matplotlib.pyplot import show
from themisasi import altfiducial
from themisasi.plots import plotthemis

try:
import seaborn as sns
sns.set_context('talk')

sns.set_context("talk")
except ImportError:
pass


sitereq = 'whit' # 'fykn' 'gako' 'mcgr'
sitereq = "whit" # 'fykn' 'gako' 'mcgr'
# for this date, kian and whit are binned 32x32, we'd need to figure out the non-trivial binning to use them.
# kian and whit are far away, so this is a low priority.

# treq = (datetime(2013,4,14,8,30),datetime(2013,4,14,8,32)) #when big auroral hook form for orientation happens
treq = (datetime(2013, 4, 14, 8, 53), datetime(
2013, 4, 14, 8, 56)) # HIST event
treq = (datetime(2013, 4, 14, 8, 53), datetime(2013, 4, 14, 8, 56)) # HIST event
odir = None

moviefn = f'THEMIS/{sitereq}_hst0,1_{treq[0].strftime("%Y-%m-%dT%H%M")}.mkv'
# %%

if sitereq == 'fykn':
asifn = 'THEMIS/thg_l1_asf_fykn_2013041408_v01.cdf'
asical = 'THEMIS/cal/themis_skymap_fykn_20110305-+_vXX.sav'
elif sitereq == 'gako':
asifn = 'THEMIS/thg_l1_asf_gako_2013041408_v01.cdf'
asical = 'THEMIS/cal/themis_skymap_gako_20110305-+_vXX.sav'
elif sitereq == 'mcgr':
asifn = 'THEMIS/thg_l1_asf_mcgr_2013041408_v01.cdf'
asical = 'THEMIS/cal/themis_skymap_mcgr_20110305-+_vXX.sav'
elif sitereq == 'inuv':
asifn = 'THEMIS/thg_l1_asf_inuv_2013041408_v01.cdf'
asical = 'THEMIS/cal/themis_skymap_inuv_20150401-+_vXX.sav'
elif sitereq == 'kian':
asifn = 'THEMIS/thg_l1_ast_kian_20130414_v01.cdf'
asical = 'THEMIS/cal/themis_skymap_kian_20111107-+_vXX.sav'
elif sitereq == 'whit':
asifn = 'THEMIS/thg_l1_ast_whit_20130414_v01.cdf'
asical = 'THEMIS/cal/themis_skymap_whit_20150814-+_vXX.sav'
if sitereq == "fykn":
asifn = "THEMIS/thg_l1_asf_fykn_2013041408_v01.cdf"
asical = "THEMIS/cal/themis_skymap_fykn_20110305-+_vXX.sav"
elif sitereq == "gako":
asifn = "THEMIS/thg_l1_asf_gako_2013041408_v01.cdf"
asical = "THEMIS/cal/themis_skymap_gako_20110305-+_vXX.sav"
elif sitereq == "mcgr":
asifn = "THEMIS/thg_l1_asf_mcgr_2013041408_v01.cdf"
asical = "THEMIS/cal/themis_skymap_mcgr_20110305-+_vXX.sav"
elif sitereq == "inuv":
asifn = "THEMIS/thg_l1_asf_inuv_2013041408_v01.cdf"
asical = "THEMIS/cal/themis_skymap_inuv_20150401-+_vXX.sav"
elif sitereq == "kian":
asifn = "THEMIS/thg_l1_ast_kian_20130414_v01.cdf"
asical = "THEMIS/cal/themis_skymap_kian_20111107-+_vXX.sav"
elif sitereq == "whit":
asifn = "THEMIS/thg_l1_ast_whit_20130414_v01.cdf"
asical = "THEMIS/cal/themis_skymap_whit_20150814-+_vXX.sav"
else:
raise ValueError(f'site {sitereq} not configured')
raise ValueError(f"site {sitereq} not configured")

ocal = ['~/code/histfeas/precompute/hst0cal.h5',
'~/code/histfeas/precompute/hst1cal.h5']
ocal = ["~/code/histfeas/precompute/hst0cal.h5", "~/code/histfeas/precompute/hst1cal.h5"]

# %%
try:
plotthemis(imgs, t, site, treq, moviefn, rows=R, cols=C,
ext=(wC[0, 0], wC[0, -1], wR[-1, 0], wR[0, 0]))
plotthemis(imgs, t, site, treq, moviefn, rows=R, cols=C, ext=(wC[0, 0], wC[0, -1], wR[-1, 0], wR[0, 0]))
except NameError:
# 60 second computation
imgs, R, C, t, site, wR, wC = altfiducial(asifn, asical, ocal, treq, odir)
Expand Down
10 changes: 5 additions & 5 deletions PlotCameraResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import numpy as np
from matplotlib.pyplot import figure, show

camfn = 'data/icx249al_response.csv'
filtfn = 'data/ir_filter.csv'
camfn = "data/icx249al_response.csv"
filtfn = "data/ir_filter.csv"

resp = pandas.read_csv(camfn, index_col=0)
filt = pandas.read_csv(filtfn, index_col=0)
Expand All @@ -22,8 +22,8 @@
filt.plot(ax=ax)

ax.grid(True)
ax.set_title('THEMIS GBO ASI spectral response')
ax.set_xlabel('wavelength [nm]')
ax.set_ylabel('normalized')
ax.set_title("THEMIS GBO ASI spectral response")
ax.set_xlabel("wavelength [nm]")
ax.set_ylabel("normalized")

show()
14 changes: 7 additions & 7 deletions PlotThemis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@


def main():
p = ArgumentParser(description=' reads THEMIS GBO ASI CDF files and plays high speed video')
p.add_argument('path', help='directory THEMIS ASI video files are in')
p.add_argument('site', help='THEMIS ASI site code e.g. fykn')
p.add_argument('treq', help='time or start,stop time range requested', nargs='+')
p.add_argument('-o', '--odir', help='write video to this directory')
p = ArgumentParser(description=" reads THEMIS GBO ASI CDF files and plays high speed video")
p.add_argument("path", help="directory THEMIS ASI video files are in")
p.add_argument("site", help="THEMIS ASI site code e.g. fykn")
p.add_argument("treq", help="time or start,stop time range requested", nargs="+")
p.add_argument("-o", "--odir", help="write video to this directory")
P = p.parse_args()

imgs = ta.load(P.path, site=P.site, treq=P.treq)
# %% plot
# %% plot
tap.plotazel(imgs)

tap.plotasi(imgs, P.odir)


if __name__ == '__main__':
if __name__ == "__main__":
main()
Loading

0 comments on commit 7602f28

Please sign in to comment.