Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update field line example #85

Merged
merged 9 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: CI

on:
push:
branches:
- '*'
- '!*backport*'
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
coverage: codecov
envs: |
- linux: py39
- linux: codestyle
pytest: false

test:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
submodules: false
coverage: codecov
envs: |
- macos: py38

docs:
needs: [core]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@main
with:
default_python: '3.9'
pytest: false
libraries: |
apt:
- graphviz
envs: |
- linux: build_docs

publish:
# Build wheels when pushing to any branch except main
# publish.yml will only publish if tagged ^v.*
if: |
(
github.event_name != 'pull_request' && (
github.ref_name != 'main' ||
github.event_name == 'workflow_dispatch'
)
) || (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Run publish')
)
needs: [test]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
with:
test_extras: 'dev'
test_command: 'pytest -p no:warnings --doctest-rst -m "not mpl_image_compare" --pyargs pyvista'
secrets:
pypi_token: ${{ secrets.pypi_token }}
37 changes: 0 additions & 37 deletions .github/workflows/python-test-workflow.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/tests.yml

This file was deleted.

98 changes: 31 additions & 67 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,95 +1,59 @@
ci:
autofix_prs: false
repos:
# The warnings/errors we check for here are:
# E101 - mix of tabs and spaces
# E11 - Fix indentation.
# E111 - 4 spaces per indentation level
# E112 - 4 spaces per indentation level
# E113 - 4 spaces per indentation level
# E121 - Fix indentation to be a multiple of four.
# E122 - Add absent indentation for hanging indentation.
# E123 - Align closing bracket to match opening bracket.
# E124 - Align closing bracket to match visual indentation.
# E125 - Indent to distinguish line from next logical line.
# E126 - Fix over-indented hanging indentation.
# E127 - Fix visual indentation.
# E128 - Fix visual indentation.
# E129 - Fix visual indentation.
# E131 - Fix hanging indent for unaligned continuation line.
# E133 - Fix missing indentation for closing bracket.
# E20 - Remove extraneous whitespace.
# E211 - Remove extraneous whitespace.
# E231 - Add missing whitespace.
# E241 - Fix extraneous whitespace around keywords.
# E242 - Remove extraneous whitespace around operator.
# E251 - Remove whitespace around parameter '=' sign.
# E252 - Missing whitespace around parameter equals.
# E26 - Fix spacing after comment hash for inline comments.
# E265 - Fix spacing after comment hash for block comments.
# E266 - Fix too many leading '#' for block comments.
# E27 - Fix extraneous whitespace around keywords.
# E301 - Add missing blank line.
# E302 - Add missing 2 blank lines.
# E303 - Remove extra blank lines.
# E304 - Remove blank line following function decorator.
# E305 - expected 2 blank lines after class or function definition
# E305 - Expected 2 blank lines after end of function or class.
# E306 - expected 1 blank line before a nested definition
# E306 - Expected 1 blank line before a nested definition.
# E401 - Put imports on separate lines.
# E402 - Fix module level import not at top of file
# E502 - Remove extraneous escape of newline.
# E701 - Put colon-separated compound statement on separate lines.
# E711 - Fix comparison with None.
# E712 - Fix comparison with boolean.
# E713 - Use 'not in' for test for membership.
# E714 - Use 'is not' test for object identity.
# E722 - Fix bare except.
# E731 - Use a def when use do not assign a lambda expression.
# 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
# W291 - Remove trailing whitespace.
# W292 - Add a single newline at the end of the file.
# W293 - Remove trailing whitespace on blank line.
# W391 - Remove trailing blank lines.
# W601 - Use "in" rather than "has_key()".
# W602 - Fix deprecated form of raising exception.
# W603 - Use "!=" instead of "<>"
# W604 - Use "repr()" instead of backticks.
# W605 - Fix invalid escape sequence 'x'.
# W690 - Fix various deprecated code (via lib2to3).
# Others are taken care of by autopep8
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args: ['--count', '--select', 'E101,E11,E111,E112,E113,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E133,E20,E211,E231,E241,E242,E251,E252,E26,E265,E266,E27,E301,E302,E303,E304,E305,E306,E401,E402,E502,E701,E711,E712,E713,E714,E722,E731,E901,E902,F822,F823,W191,W291,W292,W293,W391,W601,W602,W603,W604,W605,W690']
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|__init__.py)$"
args:
[
"--count",
"--select",
"E901,E902,F822,F823",
]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md|cm/__init__.py|sunpy/extern|sunpy/visualization/colormaps/color_tables.py)$"
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|__init__.py|docs/conf.py)$"
args:
[
"--in-place",
"--remove-all-unused-imports",
"--remove-unused-variable",
]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md|__init__.py|sunpy/extern|docs/conf.py)$"
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ['--sp','setup.cfg']
exclude: ".*(.fits|.fts|.fit|.txt|tca.*|extern.*|.rst|.md|docs/conf.py)$"
args: ["--sp", "setup.cfg"]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md|cm/__init__.py|sunpy/extern|docs/conf.py)$"
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.6.0
hooks:
- id: autopep8
args: ["--in-place","--max-line-length", "200"]
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*|extern.*|.rst|.md|cm/__init__.py|sunpy/extern|sunpy/visualization/colormaps/color_tables.py)$"
- 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|.txt)$"
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|.txt|tca.*)$"
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.txt|tca.*)$"
exclude: ".*(.fits|.fts|.fit|.header|.txt|tca.*)$"

ci:
autofix_prs: false
22 changes: 15 additions & 7 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.9"
apt_packages:
- graphviz

sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false

python:
install:
- method: pip
extra_requirements:
- dev
path: .
install:
- method: pip
extra_requirements:
- all
- docs
path: .
15 changes: 6 additions & 9 deletions examples/3d_functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,32 @@
from sunkit_pyvista.sample import low_res_aia_193

###############################################################################
# We will firstly use an AIA 193 image from the sunpy sample data as the base image.
m = low_res_aia_193()

###############################################################################
# We will use an AIA 193 image from the sunpy sample data as the base image.
# Start by creating a plotter
plotter = SunpyPlotter()
# Plot a map
plotter.plot_map(m, clip_interval=(1, 99.9)*u.percent)
plotter.plot_map(low_res_aia_193, clip_interval=(1, 99.9)*u.percent)
# Add an arrow to show the solar rotation axis
plotter.plot_solar_axis()

###############################################################################
# We can also plot an arbitrary point by passing a single coordinate to
# :meth:`~sunkit_pyvista.plotter.SunpyPlotter.plot_coordinates`.
# Plotting a point on the brightest pixel in the map
pixel_pos = np.argwhere(m.data == m.data.max()) * u.pixel
hpc_max = m.pixel_to_world(pixel_pos[:, 1], pixel_pos[:, 0])
pixel_pos = np.argwhere(low_res_aia_193.data == low_res_aia_193.data.max()) * u.pixel
hpc_max = low_res_aia_193.pixel_to_world(pixel_pos[:, 1], pixel_pos[:, 0])
plotter.plot_coordinates(hpc_max, color='blue')

# Plot a quadrangle with width of 20 degrees and a height of 60 degrees
bottom_left = SkyCoord(30*u.deg, -10*u.deg,
frame=frames.HeliographicStonyhurst,
obstime=m.date)
obstime=low_res_aia_193.date)
plotter.plot_quadrangle(bottom_left=bottom_left, width=20*u.deg,
height=60*u.deg, color='blue')

# Set the camera coordinate to view the plot correctly
camera_coord = SkyCoord(30*u.deg, -10*u.deg, 6*R_sun,
frame=frames.HeliographicStonyhurst,
obstime=m.date)
obstime=low_res_aia_193.date)
plotter.set_camera_coordinate(camera_coord)
plotter.show()
6 changes: 2 additions & 4 deletions examples/assume_spherical.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@
By default sunkit-pyvista plots all pixels in a map, using
:meth:`sunpy.coordinates.Helioprojective.assume_spherical_screen` to project
off-limb pixels on to a spherical screen. This example shows how off-limb
pixels can be ingored altogether.
pixels can be ignored altogether.
"""

import astropy.units as u

from sunkit_pyvista import SunpyPlotter
from sunkit_pyvista.sample import low_res_aia_193

m = low_res_aia_193()

plotter = SunpyPlotter()
plotter.plot_map(m, clip_interval=[1, 99] * u.percent,
plotter.plot_map(low_res_aia_193, clip_interval=[1, 99] * u.percent,
assume_spherical_screen=False)
plotter.show()
Loading