-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from jmbhughes/v1.0
V1.0
- Loading branch information
Showing
7 changed files
with
200 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# 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.10"] | ||
|
||
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 | ||
python -m pip install flake8 pytest pytest-cov hypothesis | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- 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 . | ||
pytest --cov | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v3 | ||
with: | ||
fail_ci_if_error: true | ||
verbose: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pyqt5 >= 5.15.9 | ||
matplotlib >= 3.7.2 | ||
astropy >= 5.3.1 | ||
numpy >= 1.25.1 | ||
goes-solar-retriever >= 0.4.0 | ||
scipy >= 1.11.1 | ||
scikit-image >= 0.21.0 | ||
pillow >= 10.0.0 | ||
sunpy >= 5.0.0 | ||
lxml >= 4.9.3 | ||
reproject >= 0.11.0 | ||
zeep >= 4.2.1 | ||
drms >= 0.6.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from solarannotator.io import ImageSet, ThematicMap | ||
from datetime import datetime, timedelta | ||
import numpy as np | ||
|
||
|
||
def create_mask(radius, image_size): | ||
""" | ||
Inputs: | ||
- Radius: Radius (pixels) within which a certain theme should be assigned | ||
- Image size: tuple of (x, y) size (pixels) that represents size of image | ||
""" | ||
# Define image center | ||
center_x = (image_size[0] / 2) - 0.5 | ||
center_y = (image_size[1] / 2) - 0.5 | ||
|
||
# Create mesh grid of image coordinates | ||
xm, ym = np.meshgrid(np.linspace(0, image_size[0] - 1, num=image_size[0]), | ||
np.linspace(0, image_size[1] - 1, num=image_size[1])) | ||
|
||
# Center each mesh grid (zero at the center) | ||
xm_c = xm - center_x | ||
ym_c = ym - center_y | ||
|
||
# Create array of radii | ||
rad = np.sqrt(xm_c ** 2 + ym_c ** 2) | ||
|
||
# Create empty mask of same size as the image | ||
mask = np.zeros((image_size[0], image_size[1])) | ||
|
||
# Apply the mask as true for anything within a radius | ||
mask[(rad < radius)] = 1 | ||
|
||
# Return the mask | ||
return mask.astype('bool') | ||
|
||
|
||
def create_thmap_template(image_set, limb_thickness=10): | ||
""" | ||
Input: Image set object as input, and limb thickness in pixels | ||
Output: thematic map object | ||
Process: | ||
- Get the solar radius with predefined function | ||
- Create empty thematic map | ||
- Define concentric layers separated by solar radius + limb thickness, and create thmap | ||
- Return the thematic map object | ||
Note copied from Alison Jarvis | ||
""" | ||
|
||
# Get the solar radius with class function | ||
solar_radius = image_set.get_solar_radius() | ||
|
||
# Define end of disk and end of limb radii | ||
disk_radius = solar_radius - (limb_thickness / 2) | ||
limb_radius = solar_radius + (limb_thickness / 2) | ||
|
||
# Create concentric layers for disk, limb, and outer space | ||
# First template layer, outer space (value 1) with same size as composites | ||
imagesize = np.shape(image_set['171'].data) | ||
thmap_data = np.ones(imagesize) | ||
# Mask out the limb (value 8) | ||
limb_mask = create_mask(limb_radius, imagesize) | ||
thmap_data[limb_mask] = 8 | ||
# Mask out the disk with quiet sun (value 7) | ||
qs_mask = create_mask(disk_radius, imagesize) | ||
thmap_data[qs_mask] = 7 | ||
|
||
# Create a thematic map object with this data and return it | ||
theme_mapping = {1: 'outer_space', 3: 'bright_region', 4: 'filament', 5: 'prominence', 6: 'coronal_hole', | ||
7: 'quiet_sun', 8: 'limb', 9: 'flare'} | ||
thmap_template = ThematicMap(thmap_data, {'DATE-OBS': image_set['171'].header['DATE-OBS']}, theme_mapping) | ||
|
||
# Return the thematic map object | ||
return thmap_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from solarannotator.template import create_mask | ||
|
||
|
||
def test_mask_creation(): | ||
mask = create_mask(500, (2048, 2048)) | ||
assert not mask[0, 0] | ||
assert mask[1024, 1024] |