Skip to content

Commit

Permalink
Added vmac to photospheres
Browse files Browse the repository at this point in the history
  • Loading branch information
aasensio committed Nov 6, 2019
1 parent 5f57e63 commit 54436b5
Show file tree
Hide file tree
Showing 60 changed files with 159 additions and 97 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,13 @@ Install the following packages:

And then compile them typing the following in the ``docs`` directory:

./compile
./compile

## Issues

MacOSX Catalina has some issues with the paths to the include files. Defining the following environment variables might help.

export CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
export CCFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
export CXXFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
export CPPFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
15 changes: 10 additions & 5 deletions docs/io_files/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,13 @@ be perturbed with nodes until a fit is obtained for the observed Stokes paramete
These are text files which tabulates the depth dependence as a function of the log optical depth at 500 nm
of the temperature [K], electron pressure [cgs],
microturbulent velocity [cm/s], bulk velocity [cm/s], and the cartesian components of the magnetic field,
Bx, By and Bz [G]. Additionally, the filling factor is given in the header. An example follows:
Bx, By and Bz [G]. Additionally, the filling factor and the macroscopic velocity in km/s
is given in the header. An example follows:

::

ff
1.0
ff vmac
1.0 1.0

logtau T Pe vmic v Bx By Bz
1.2000 8879.7 2.99831E+03 0.000E+00 0.0000E+00 5.0000E+02 0.0000E+00 0.0000E+00
Expand All @@ -164,9 +165,10 @@ Bx, By and Bz [G]. Additionally, the filling factor is given in the header. An e
HDF5/zarr 3D files
^^^^^^^^^^^^^^^^^^

HDF5/zarr files with model photospheres are defined with two double-precision datasets: ``model`` and ``ff``. The first
HDF5/zarr files with model photospheres are defined with three double-precision datasets: ``model``, ``ff`` and ``vmac``. The first
one has size ``(n_pixel,nz,8)``, containing the depth dependence of the 8 variables for all pixels. The second
one has size ``(n_pixel,)``, containing the filling factor for each pixel. In the following we show how to
and the third ones have sizes ``(n_pixel,)``, containing the filling factor and the macroscopic velocity
for each pixel. In the following we show how to
create a sample file:

::
Expand All @@ -176,12 +178,15 @@ create a sample file:
model_3d = np.zeros((n_pixel,nz,8), dtype=np.float64)
ff_3d = np.zeros((n_pixel,), dtype=np.float64)
vmac_3d = np.zeros((n_pixel,), dtype=np.float64)

f = h5py.File('photospheres/model_photosphere.h5', 'w')
db_model = f.create_dataset('model', model_3d.shape, dtype=np.float64)
db_ff = f.create_dataset('ff', ff_3d.shape, dtype=np.float64)
db_vmac = f.create_dataset('vmac', vmac_3d.shape, dtype=np.float64)
db_model[:] = model_3d
db_ff[:] = ff_3d
db_vmac[:] = vmac_3d
f.close()

FITS 3D files
Expand Down
7 changes: 5 additions & 2 deletions examples/configurations/conf_single.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[Working mode]
Output file = output.h5
Number of cycles = 2
Number of cycles = 1

# Topology
# Always photosphere and then chromosphere
Expand Down Expand Up @@ -46,6 +46,7 @@ Number of cycles = 2
By = -1000.0, 1000.0
Bz = -1000.0, 1000.0
ff = 0.0, 1.001
vmac = 0.0, 5.0

[[[Nodes]]]
T = 2, 2, 5, 5
Expand All @@ -55,15 +56,17 @@ Number of cycles = 2
By = 0, 1, 1, 1
Bz = 0, 1, 1, 1
ff = 0, 0, 0, 0
vmac = 0, 0, 0, 0

[[[Regularization]]]
T = 'l2-value', 10.0, 1.0
T = 'l2-value', 0.0, 5000.0
vmic = None
v = None
Bx = None
By = None
Bz = None
ff = None
vmac = None


[[Chromosphere 1]]
Expand Down
10 changes: 5 additions & 5 deletions examples/example_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import gc

# Test a single inversion in non-iterator mode
mod = hazel.Model('conf_single.ini', working_mode='inversion', verbose=2)
mod = hazel.Model('configurations/conf_single.ini', working_mode='inversion', verbose=2)
mod.read_observation()
mod.open_output()
mod.invert()
Expand All @@ -16,14 +16,14 @@

final = np.loadtxt('photospheres/model_photosphere.1d', skiprows=4)
start = np.loadtxt('photospheres/model_photosphere_200.1d', skiprows=4)
f = h5py.File('output.h5')
f = h5py.File('output.h5', 'r')
pl.plot(f['ph1']['T'][0,0,:], label='inverted')
pl.plot(final[:,1], label='target')
pl.plot(start[:,1], 'x', label='initial')
f.close()
pl.legend()

mod = hazel.Model('conf_single.ini', working_mode='inversion', verbose=2)
mod = hazel.Model('configurations/conf_single.ini', working_mode='inversion', verbose=2)
mod.read_observation()
mod.open_output()
mod.invert_external(minimize, method='Nelder-Mead')
Expand All @@ -32,7 +32,7 @@

final = np.loadtxt('photospheres/model_photosphere.1d', skiprows=4)
start = np.loadtxt('photospheres/model_photosphere_200.1d', skiprows=4)
f = h5py.File('output.h5')
f = h5py.File('output.h5', 'r')

pl.figure()
pl.plot(f['ph1']['T'][0,0,:], label='inverted')
Expand All @@ -41,4 +41,4 @@
f.close()
pl.legend()

pl.show()
pl.show()
2 changes: 1 addition & 1 deletion examples/example_single_inv.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

final = np.loadtxt('photospheres/model_photosphere.1d', skiprows=4)
start = np.loadtxt('photospheres/model_photosphere_200.1d', skiprows=4)
f = h5py.File('output.h5')
f = h5py.File('output.h5', 'r')
fig = pl.figure()
pl.plot(f['ph1']['T'][0,0,0,:])
pl.plot(final[:,1])
Expand Down
2 changes: 0 additions & 2 deletions examples/gen_model.py

This file was deleted.

Binary file added examples/output.h5
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/photospheres/model_photosphere.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.2000 8879.7 2.99831E+03 0.000E+00 0.0000E+00 5.0000E+02 0.0000E+00 0.0000E+00
Expand Down
Binary file modified examples/photospheres/model_photosphere.h5
100755 → 100644
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/photospheres/model_photosphere_200.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 1.0

logtau T Pe vmic v Bx By Bz
1.2000e+00 8.6797e+03 -2.9983e+03 1.0000e+00 0.0000e+00 5.0000e+02 0.0000e+00 0.0000e+00
Expand Down
1 change: 1 addition & 0 deletions hazel/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class General_atmosphere(object):
def __init__(self, atm_type, name):
self.ff = 1.0
self.name = name
self.type = atm_type

self.logger = logging.getLogger("model")
self.logger.setLevel(logging.DEBUG)
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALB.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.300 9150.7 3.719000e+03 2.72 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALC11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 9427.2 5.140000e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALD.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.300 9118.0 3.650000e+03 2.73 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALE11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 9433.3 5.176000e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALF.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.300 9032.2 3.367000e+03 2.73 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALF11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 9443.1 5.236000e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALH.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.500 9002.3 3.299000e+03 2.72 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALH11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 9446.1 5.265000e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALP.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.300 8510.2 1.819000e+03 1.83 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALP11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.100 8692.4 2.308000e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALR11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 8763.8 2.949000e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALS.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 6628.7 2.439000e+02 1.20 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/FALS11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.300 6957.0 4.114000e+02 0.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/cool11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 6780.3 3.372810e+02 0.60 246200.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/emaltby11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.200 6710.0 2.488480e+02 0.60 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/grevesse11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.900 10220.0 1.082510e+04 0.60 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/holmu11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.250 8793.9 2.679730e+03 1.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/hot11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 8004.6 1.551370e+03 0.60 10000.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/hsra.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.2000 8879.7 2.99831E+03 0.000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/hsra11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.400 9560.0 6.046790e+03 0.60 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/mackkl11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.200 9117.1 3.316670e+03 0.00 100000.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/mmaltby11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.200 6700.0 2.612010e+02 1.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/penumjti11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.200 8461.0 2.030960e+03 0.60 200000.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/solannt11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.000 8700.0 1.989200e+03 3.00 0.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/solanpl11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.200 9918.0 7.546820e+03 0.60 100000.00 0.00 0.00 0.00
Expand Down
4 changes: 2 additions & 2 deletions hazel/data/valc11.1d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ff
1.0
ff vmac
1.0 0.0

logtau T Pe vmic v Bx By Bz
1.200 8879.7 2.998310e+03 0.00 0.00 0.00 0.00 0.00
Expand Down
Loading

0 comments on commit 54436b5

Please sign in to comment.