Skip to content

Commit c45f6aa

Browse files
authored
Rename Loop to Strand (#98)
* infrastructure cleanup * rename Loop->Strand * fix circular import
1 parent ecb6d61 commit c45f6aa

19 files changed

+244
-258
lines changed
File renamed without changes.

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
<div align="center">
2-
<img src="docs/_static/synthesizar_logo.png" width=55%><br>
3-
</div>
4-
51
# synthesizAR
2+
63
[![Powered by SunPy Badge]( http://img.shields.io/badge/powered%20by-SunPy-orange.svg?style=flat)](http://www.sunpy.org)
7-
![synthesizAR CI status](https://github.com/wtbarnes/synthesizAR/workflows/Run%20tests/badge.svg)
4+
[![synthesizAR CI status](https://github.com/wtbarnes/synthesizAR/actions/workflows/ci.yml/badge.svg)](https://github.com/wtbarnes/synthesizAR/actions/workflows/ci.yml)
85
[![Documentation Status](http://readthedocs.org/projects/synthesizar/badge/?version=latest)](http://synthesizar.readthedocs.io/en/latest/?badge=latest)
9-
[![codecov](https://codecov.io/gh/wtbarnes/synthesizAR/branch/master/graph/badge.svg)](https://codecov.io/gh/wtbarnes/synthesizAR)
6+
[![codecov](https://codecov.io/gh/wtbarnes/synthesizAR/graph/badge.svg?token=QUTQZGWQKB)](https://codecov.io/gh/wtbarnes/synthesizAR)
107

11-
synthesizAR is a Python package for forward modeling emission from solar active regions using hydrodynamic simulations of coronal loops
8+
synthesizAR is a Python package for forward modeling optically-thin emission from field-aligned hydrodynamic simulations of astrophysical plasmas.
129

1310
## Install
11+
1412
To clone the repository and install the package and all of its needed dependencies,
13+
1514
```shell
16-
$ git clone https://github.com/wtbarnes/synthesizAR.git
17-
$ cd synthesizAR
18-
$ pip install -e .[all]
15+
git clone https://github.com/wtbarnes/synthesizAR.git
16+
cd synthesizAR
17+
pip install -e .[all]
1918
```
2019

2120
## Help
21+
2222
See the [docs](http://synthesizar.readthedocs.io). To report bugs or request features, create an issue or submit a pull request.

examples/arcade-rtv.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
of semi-circular loops who's thermal structure is modeled
77
using the RTV scaling laws.
88
"""
9-
import astropy.units as u
109
import astropy.time
10+
import astropy.units as u
11+
1112
from astropy.coordinates import SkyCoord
1213
from sunpy.coordinates import get_earth
1314

1415
import synthesizAR
15-
from synthesizAR.models import semi_circular_arcade
16-
from synthesizAR.interfaces import RTVInterface
16+
1717
from synthesizAR.instruments import InstrumentSDOAIA
18+
from synthesizAR.interfaces import RTVInterface
19+
from synthesizAR.models import semi_circular_arcade
1820

1921
#########################################################################
2022
# First, set up the coordinates for loops in the arcade.
@@ -24,7 +26,7 @@
2426

2527
#########################################################################
2628
# Next, assemble the arcade.
27-
strands = [synthesizAR.Loop(f'strand{i}', c) for i, c in enumerate(arcade_coords)]
29+
strands = [synthesizAR.Strand(f'strand{i}', c) for i, c in enumerate(arcade_coords)]
2830
arcade = synthesizAR.Skeleton(strands)
2931

3032
#########################################################################

examples/loop-bundle-rtv.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,20 @@
66
bundle of semi-circular strands for two different
77
viewpoints.
88
"""
9-
import matplotlib.pyplot as plt
109
import astropy.time
1110
import astropy.units as u
12-
from astropy.visualization import quantity_support
11+
import matplotlib.pyplot as plt
12+
1313
from astropy.coordinates import SkyCoord
14+
from astropy.visualization import quantity_support
1415
from sunpy.map import pixelate_coord_path, sample_at_coords
1516

1617
import synthesizAR
18+
1719
from synthesizAR.instruments import InstrumentSDOAIA
1820
from synthesizAR.interfaces import RTVInterface
1921
from synthesizAR.models import semi_circular_bundle
22+
2023
# sphinx_gallery_thumbnail_number = -1
2124

2225
###########################################################################
@@ -32,7 +35,7 @@
3235
###########################################################################
3336
# As in other examples, we then use the coordinates of our strands to
3437
# construct the `~synthesizAR.Skeleton` object.
35-
strands = [synthesizAR.Loop(f'strand{i}', c) for i, c in enumerate(bundle_coords)]
38+
strands = [synthesizAR.Strand(f'strand{i}', c) for i, c in enumerate(bundle_coords)]
3639
bundle = synthesizAR.Skeleton(strands)
3740
bundle.peek(observer=pos)
3841

examples/multi-instrument.py

+16-8
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,24 @@
99
instrument class.
1010
"""
1111
import astropy.units as u
12-
from astropy.coordinates import SkyCoord
13-
import numpy as np
1412
import matplotlib.pyplot as plt
15-
from sunpy.coordinates import get_earth, get_horizons_coord, HeliographicStonyhurst, Helioprojective
13+
import numpy as np
14+
15+
from astropy.coordinates import SkyCoord
1616
from astropy.visualization import quantity_support
17+
from sunpy.coordinates import (
18+
get_earth,
19+
get_horizons_coord,
20+
HeliographicStonyhurst,
21+
Helioprojective,
22+
)
1723

1824
import synthesizAR
19-
from synthesizAR.models import semi_circular_arcade
25+
26+
from synthesizAR.instruments import InstrumentHinodeXRT, InstrumentSDOAIA
2027
from synthesizAR.interfaces import MartensInterface
21-
from synthesizAR.instruments import InstrumentSDOAIA, InstrumentHinodeXRT
28+
from synthesizAR.models import semi_circular_arcade
29+
2230
# sphinx_gallery_thumbnail_number = -1
2331

2432
###############################################################################
@@ -27,7 +35,7 @@
2735
obstime = '2021-10-28T15:00:00'
2836
loc = SkyCoord(HeliographicStonyhurst(lon=0*u.deg,lat=-30*u.deg, radius=1*u.R_sun, obstime=obstime))
2937
arcade = semi_circular_arcade(150*u.Mm, 10*u.deg, 50, loc, gamma=90*u.deg, n_points=5000)
30-
skeleton = synthesizAR.Skeleton([synthesizAR.Loop(f'{i}', c) for i,c in enumerate(arcade)])
38+
skeleton = synthesizAR.Skeleton([synthesizAR.Strand(f'{i}', c) for i,c in enumerate(arcade)])
3139

3240
###############################################################################
3341
# We'll select a few different observer locations for SDO and STERO-A and use
@@ -64,10 +72,10 @@ def get_heating_constant(self, loop):
6472
with quantity_support():
6573
plt.figure(figsize=(11, 5))
6674
ax1 = plt.subplot(121)
67-
for l in skeleton.loops:
75+
for l in skeleton.strands:
6876
plt.plot(l.field_aligned_coordinate_center.to('Mm'), l.electron_temperature[0].to('MK'), color='k')
6977
plt.subplot(122)
70-
for l in skeleton.loops:
78+
for l in skeleton.strands:
7179
plt.plot(l.field_aligned_coordinate_center.to('Mm'), l.density[0], color='k')
7280
plt.yscale('log')
7381

licenses/README.rst

-9
This file was deleted.

licenses/TEMPLATE_LICENSE.rst

-31
This file was deleted.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ authors = [
1111
{name="Will Barnes", email="will.t.barnes@gmail.com"}
1212
]
1313
license = {file="LICENSE.rst"}
14-
description = "A Python package for forward-modeling optically-thin emission from field-aligned coronal loop models"
14+
description = "A Python package for forward modeling optically-thin emission from field-aligned hydrodynamic simulations of astrophysical plasmas."
1515
readme = {file="README.md", content-type = "text/markdown"}
1616
requires-python = ">=3.10"
1717
dependencies = [

synthesizAR/__init__.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
hydrodynamic simulations of coronal loops.
44
"""
55
try:
6-
from .version import __version__
6+
from synthesizAR.version import __version__
77
except ImportError:
88
__version__ = "unknown"
99

1010

11-
from .loop import *
12-
from .skeleton import *
13-
1411
# Set up logger
1512
from synthesizAR.util.logger import _init_log
13+
14+
from .strand import * # NOQA
15+
from .skeleton import * # NOQA
16+
1617
log = _init_log()

synthesizAR/conftest.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
"""
22
Configure test skeletons here so that they can be used everywhere
33
"""
4+
import astropy.units as u
45
import pytest
56

6-
import astropy.units as u
77
from sunpy.coordinates import get_earth
88

99
import synthesizAR
10-
from synthesizAR.models import semi_circular_loop, semi_circular_arcade
10+
1111
from synthesizAR.interfaces import MartensInterface
12+
from synthesizAR.models import semi_circular_arcade, semi_circular_loop
1213

1314

1415
@pytest.fixture
1516
def bare_skeleton():
1617
observer = get_earth(time='2020-01-01T00:00:00')
1718
arcade = semi_circular_arcade(100*u.Mm, 20*u.deg, 10, observer)
18-
loops = [synthesizAR.Loop(f'{i}', c) for i, c in enumerate(arcade)]
19+
loops = [synthesizAR.Strand(f'{i}', c) for i, c in enumerate(arcade)]
1920
return synthesizAR.Skeleton(loops)
2021

2122

@@ -29,4 +30,4 @@ def skeleton_with_model(bare_skeleton):
2930
@pytest.fixture
3031
def semi_circle_strand(bare_skeleton):
3132
coords = semi_circular_loop(length=100*u.Mm)
32-
return synthesizAR.Loop('test', coords)
33+
return synthesizAR.Strand('test', coords)

synthesizAR/instruments/base.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
"""
22
Base class for instrument objects.
33
"""
4+
import astropy.units as u
45
import copy
5-
import tempfile
6+
import numpy as np
67
import pathlib
7-
from dataclasses import dataclass
8+
import tempfile
9+
import zarr
810

9-
import numpy as np
11+
from astropy.coordinates import SkyCoord
12+
from dataclasses import dataclass
1013
from scipy.interpolate import interp1d
1114
from scipy.ndimage import gaussian_filter
12-
import astropy.units as u
13-
from astropy.coordinates import SkyCoord
14-
from sunpy.coordinates.frames import Helioprojective, HeliographicStonyhurst
15+
from sunpy.coordinates.frames import HeliographicStonyhurst, Helioprojective
1516
from sunpy.map import make_fitswcs_header, Map
16-
import zarr
1717

18-
from synthesizAR.util import is_visible, find_minimum_fov
18+
from synthesizAR.util import find_minimum_fov, is_visible
1919
from synthesizAR.util.decorators import return_quantity_as_tuple
2020

2121
__all__ = ['ChannelBase', 'InstrumentBase']
@@ -27,7 +27,7 @@ class ChannelBase:
2727
channel: u.Quantity = None
2828

2929

30-
class InstrumentBase(object):
30+
class InstrumentBase:
3131
"""
3232
Base class for instruments. This object is not meant to be instantiated directly. Instead,
3333
specific instruments should subclass this base object and implement a
@@ -170,17 +170,17 @@ def observe(self, skeleton, save_directory=None, channels=None, **kwargs):
170170
if client:
171171
# Parallel
172172
kernel_futures = client.map(self.calculate_intensity_kernel,
173-
skeleton.loops,
173+
skeleton.strands,
174174
channel=channel,
175175
**kwargs)
176176
kernel_interp_futures = client.map(self.interpolate_to_instrument_time,
177177
kernel_futures,
178-
skeleton.loops,
178+
skeleton.strands,
179179
observing_time=(self.observing_time.value, self.observing_time.unit.to_string()))
180180
else:
181181
# Serial
182182
kernels_interp = []
183-
for l in skeleton.loops:
183+
for l in skeleton.strands:
184184
k = self.calculate_intensity_kernel(l, channel=channel, **kwargs)
185185
k = self.interpolate_to_instrument_time(
186186
k, l, observing_time=(self.observing_time.value, self.observing_time.unit.to_string()),
@@ -189,22 +189,22 @@ def observe(self, skeleton, save_directory=None, channels=None, **kwargs):
189189

190190
if kwargs.get('save_kernels_to_disk', False):
191191
with tempfile.TemporaryDirectory() as tmpdir:
192-
self._make_stacked_kernel_array(tmpdir, skeleton.loops, channel)
193-
indices = self._find_loop_array_bounds(skeleton.loops)
192+
self._make_stacked_kernel_array(tmpdir, skeleton.strands, channel)
193+
indices = self._find_loop_array_bounds(skeleton.strands)
194194
if client:
195195
files = client.map(self.write_kernel_to_file,
196196
kernel_interp_futures,
197-
skeleton.loops,
197+
skeleton.strands,
198198
indices,
199199
channel=channel,
200200
name=self.name,
201201
tmp_store=tmpdir)
202202
# NOTE: block here to avoid pileup of tasks that can overwhelm the scheduler
203203
distributed.wait(files)
204204
else:
205-
for k, l, i in zip(kernels_interp, skeleton.loops, indices):
205+
for k, l, i in zip(kernels_interp, skeleton.strands, indices):
206206
self.write_kernel_to_file(k, l, i, channel, self.name, tmpdir)
207-
self._rechunk_stacked_kernels(tmpdir, skeleton.loops[0].model_results_filename, channel)
207+
self._rechunk_stacked_kernels(tmpdir, skeleton.strands[0].model_results_filename, channel)
208208
kernels = self.observing_time.shape[0]*[None] # placeholder so we know to read from a file
209209
else:
210210
# NOTE: this can really blow up your memory if you are not careful
@@ -336,7 +336,7 @@ def integrate_los(self, time, channel, skeleton, coordinates_centers, bins, bin_
336336
# Compute weights
337337
if kernels is None:
338338
i_time = np.where(time == self.observing_time)[0][0]
339-
root = skeleton.loops[0].zarr_root
339+
root = skeleton.strands[0].zarr_root
340340
ds = root[f'{self.name}/{channel.name}_stacked_kernels']
341341
kernels = u.Quantity(ds[i_time, :], ds.attrs['unit'])
342342
# If a volumetric quantity, integrate over the cell and normalize by pixel area.

0 commit comments

Comments
 (0)