Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sdc
GRIS Gregor Infrared Spectrograph
grisinv
Commits
2580a788
Commit
2580a788
authored
Aug 04, 2021
by
Vigeesh Gangadharan
Browse files
Merge branch 'typo_fixes'
parents
58fa7d65
0bada30e
Pipeline
#2331
passed with stage
in 2 minutes and 47 seconds
Changes
2
Pipelines
11
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
2580a788
...
...
@@ -2,7 +2,8 @@
image
:
'
continuumio/miniconda3:latest'
.before_script_linux
:
&before_script_linux
-
apt-get -qq update && apt-get -qq install -y make
-
apt-get update --fix-missing
-
apt-get -qq install -y make
-
conda create -n gris_inv -c conda-forge mpi4py numpy scipy gfortran_linux-64 lapack matplotlib
-
conda init bash
-
source ~/.bashrc
...
...
grisinv/invert.py
View file @
2580a788
...
...
@@ -193,7 +193,7 @@ def vfisv(
inv_data : dict of numpy arrays
The dict contains the following variables
S0+S1,
vel_los, inclination, azimuth, field_strength and the corresponding uncertain
i
ties
vel_los, inclination, azimuth, field_strength and the corresponding uncertainties
chi_square.
stokes_data : dict of numpy arrays
...
...
@@ -306,22 +306,6 @@ class FitsCardGroup:
self
.
cardlist
=
cardlist
self
.
header
=
None
def
add_card
(
self
,
card
):
"""
Parameters
----------
card : str
a fits keyword
Returns
-------
empty fits card with the keyword
"""
fitscard
=
fits
.
Card
(
card
,
None
,
""
)
return
fitscard
def
to_header
(
self
):
"""
...
...
@@ -339,7 +323,7 @@ class FitsCardGroup:
for
card
in
self
.
cardlist
:
if
card
!=
"HISTORY"
:
self
.
header
.
append
(
self
.
add_card
(
card
),
end
=
True
)
self
.
header
.
append
(
fits
.
Card
(
card
,
None
,
""
),
end
=
True
)
return
self
.
header
...
...
@@ -434,10 +418,6 @@ def get_stokes_fits(data, vfisv_params):
array from vfisv containing all the data
vfisv_params :
the vfisvpackage class instance that holds all the params
index : int
the index of the desired variable based on VFISV manual
units :
the astropy.units that should be assigned to the data
Returns
-------
...
...
@@ -646,11 +626,11 @@ def write_fits(data, header, out, errors=None):
out : str
Output filename
errors : str
Output filename for uncertain
i
ties
Output filename for uncertainties
"""
if
errors
==
None
:
if
errors
is
None
:
print
(
termcolors
.
text
+
f
"
\n
Writing results to
{
out
}
"
+
termcolors
.
end
,
end
=
""
)
# header.comments['NAXIS1'] = 'Length of data axis 1'
...
...
@@ -675,7 +655,7 @@ def write_fits(data, header, out, errors=None):
# adding the description
hdu
.
header
[
"BTYPE"
]
=
vfisv_naming
[
iquant
][
"annotate"
]
# adding the unit of the q
a
untity
# adding the unit of the qu
a
ntity
hdu
.
header
[
"BUNIT"
]
=
str
(
vfisv_naming
[
iquant
][
"unit"
])
# append the hdu in the list
...
...
@@ -689,10 +669,10 @@ def write_fits(data, header, out, errors=None):
out
,
overwrite
=
True
,
output_verify
=
"silentfix+exception"
,
checksum
=
True
)
if
errors
==
None
:
if
errors
is
None
:
print
(
termcolors
.
text
+
". "
+
termcolors
.
okay
+
"Done.
\n
"
+
termcolors
.
end
)
if
errors
!=
None
:
if
errors
is
not
None
:
hdu_list
=
[]
for
iquant
in
vfisv_errors_naming
:
...
...
@@ -710,7 +690,7 @@ def write_fits(data, header, out, errors=None):
# adding the description
hdu
.
header
[
"BTYPE"
]
=
vfisv_errors_naming
[
iquant
][
"annotate"
]
# adding the unit of the q
a
untity
# adding the unit of the qu
a
ntity
hdu
.
header
[
"BUNIT"
]
=
str
(
vfisv_errors_naming
[
iquant
][
"unit"
])
# append the hdu in the list
...
...
@@ -1144,7 +1124,7 @@ def plot_image(
----------
data : dict of numpy arrays
The dict contains the following variables
Contin
n
um_I, vel_los, inclination, azimuth, field_strength
Contin
u
um_I, vel_los, inclination, azimuth, field_strength
header : object
Astropy fits header
preview : str
...
...
@@ -1162,7 +1142,7 @@ def plot_image(
cfmt : str
colorbar label format
cticks : list
colobar ticks
colo
r
bar ticks
"""
...
...
@@ -1261,7 +1241,7 @@ def correct_field(data, unit_data, unit_vmax, cticks, cfmt):
# change the maximum if the max is less than the default
unit_vmax
=
(
np
.
max
(
unit_data
.
value
)
if
(
unit_vmax
!=
None
)
and
(
unit_vmax
>
np
.
max
(
unit_data
.
value
))
if
(
unit_vmax
is
not
None
)
and
(
unit_vmax
>
np
.
max
(
unit_data
.
value
))
else
unit_vmax
)
# if the field strength is large then round the max and use matplotlib ticks
...
...
@@ -1284,7 +1264,7 @@ def correct_field(data, unit_data, unit_vmax, cticks, cfmt):
def
convert_units
(
data
,
vmin
,
vmax
):
"""Convert the units of data based on vmin/vmax"""
if
vmax
==
None
:
if
vmax
is
None
:
# if vmax is not provided with a unit
unit_data
=
data
unit_vmin
=
vmin
...
...
@@ -1320,7 +1300,7 @@ def merge_to_gif(filelist, outfile):
def
switch_coordinates
(
lon
,
lat
,
canvas
):
"""in case the the labels are nor proper, switch the axis"""
# Check if the left or the bottom labels are dr
w
an.
# Check if the left or the bottom labels are dra
w
n.
# If not, then this is possibly due to slit aligned horizontally.
if
(
"l"
not
in
lat
.
ticklabels
.
text
)
or
(
"b"
not
in
lon
.
ticklabels
.
text
):
lon
.
set_ticks_position
(
"l"
)
...
...
@@ -1423,7 +1403,7 @@ def create_preview(data, header, preview):
# velocity calibration for preview images only
if
iquant
==
"vlos"
:
# setting a magnetic field mask of 1000 G
u
ass.
# setting a magnetic field mask of 1000 Ga
u
ss.
mag_mask
=
data
[
"bmag"
].
value
<
1000.0
quant_data
-=
np
.
mean
(
quant_data
[
mag_mask
])
...
...
@@ -1459,7 +1439,7 @@ def write_log_file(log, header, data, stokes, total_time, numproc):
header : object
Astropy header object
data : dict of numpy arrays
Array containing the inversion results and uncertain
i
ties
Array containing the inversion results and uncertainties
stokes : dict of numpy arrays
Array containing the stokes vector and fits
total_time : float
...
...
@@ -1496,7 +1476,7 @@ def write_log_file(log, header, data, stokes, total_time, numproc):
f
.
write
(
f
"Number of processors :
{
numproc
}
\n
"
)
f
.
write
(
f
"Total profiles inverted :
{
data
[
'vlos'
].
size
}
\n\n
"
)
# Some info about the uncertain
i
ties
# Some info about the uncertainties
f
.
write
(
f
"Mean chi_sqr :
{
data
[
'chsq'
].
value
.
mean
():
5.2
f
}
\n
"
)
f
.
write
(
f
"Best chi_sqr :
{
data
[
'chsq'
].
value
.
min
():
5.2
f
}
\n
"
)
f
.
write
(
f
"Worst chi_sqr :
{
data
[
'chsq'
].
value
.
max
():
5.2
f
}
\n
"
)
...
...
@@ -1597,7 +1577,8 @@ class VFISVpackage:
self
.
LY
=
self
.
header
[
"NAXIS2"
]
# Length of the slit
self
.
LZ
=
16
# VFISV data structure
def
get_line_list
(
self
):
@
staticmethod
def
get_line_list
():
"""Get the list of available lines"""
line_list
=
(
pkgutil
.
get_data
(
"grisinv"
,
os
.
path
.
join
(
"data_files"
,
"line_names.csv"
))
...
...
@@ -1762,10 +1743,10 @@ class VFISVpackage:
),
)
# Set the pix contin
n
um to pix_ini
# Set the pix contin
u
um to pix_ini
self
.
pix_cont
=
self
.
pix_ini
# Set the start of the waveleng
h
t array for
# Set the start of the wavelengt
h
array for
self
.
wave_start
=
wave_array
[
self
.
pix_ini
]
else
:
...
...
@@ -1923,7 +1904,7 @@ class VFISVpackage:
@
click
.
option
(
"-l"
,
"--line"
,
type
=
float
,
help
=
"Wavelength of the line Angstrom"
)
@
click
.
option
(
"-w"
,
"--width"
,
type
=
float
,
help
=
"Wavelength range in Angstrom"
)
@
click
.
option
(
"--preview"
,
type
=
str
,
help
=
"Filename to save the plot"
)
@
click
.
option
(
"--errors"
,
type
=
str
,
help
=
"Filename to save the uncertain
i
ties"
)
@
click
.
option
(
"--errors"
,
type
=
str
,
help
=
"Filename to save the uncertainties"
)
@
click
.
option
(
"--diagnose"
,
type
=
str
,
help
=
"Filename to write the inversion fits"
)
@
click
.
option
(
"--log"
,
type
=
str
,
help
=
"Filename to write the log file"
)
def
main
(
path
,
id
,
out
,
numproc
,
line
,
width
,
preview
,
errors
,
diagnose
,
log
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment