Skip to content

Commit

Permalink
move marcs regex patterns to new file
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields committed Nov 4, 2024
1 parent 0c542dc commit 28d0881
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 99 deletions.
103 changes: 4 additions & 99 deletions stardis/io/model/marcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
from stardis.model.geometry.radial1d import Radial1DGeometry
from stardis.model.base import StellarModel
from tardis.model.matter.composition import Composition
from stardis.io.model.marcs_regex_patterns import (
METADATA_PLANE_PARALLEL_RE_STR,
METADATA_SPHERICAL_RE_STR,
)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -180,105 +184,6 @@ def read_marcs_metadata(fpath, gzipped=True):
dict : dictionary
metadata parameters of file
"""

METADATA_PLANE_PARALLEL_RE_STR = [
(r"(.+)\n", "fname"),
(
r" (\d+\.)\s+Teff \[(.+)\]\.\s+Last iteration; yyyymmdd=\d+",
"teff",
"teff_units",
),
(r" (\d+\.\d+E\+\d+) Flux \[(.+)\]", "flux", "flux_units"),
(
r" (\d+.\d+E\+\d+) Surface gravity \[(.+)\]",
"surface_grav",
"surface_grav_units",
),
(
r" (\d+\.\d+)\W+Microturbulence parameter \[(.+)\]",
"microturbulence",
"microturbulence_units",
),
(r" (\d+\.\d+)\s+(No mass for plane-parallel models)", "plane_parallel_mass"),
(
r" (\+?\-?\d+.\d+) (\+?\-?\d+.\d+) Metallicity \[Fe\/H] and \[alpha\/Fe\]",
"feh",
"afe",
),
(
r" (\d+\.\d+E\+00) (1 cm radius for plane-parallel models)",
"radius for plane-parallel model",
),
(r" (\d.\d+E-\d+) Luminosity \[(.+)\]", "luminosity", "luminosity_units"),
(
r" (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+) are the convection parameters: alpha, nu, y and beta",
"conv_alpha",
"conv_nu",
"conv_y",
"conv_beta",
),
(
r" (0.\d+) (0.\d+) (\d.\d+E-\d+) are X, Y and Z, 12C\/13C=(\d+.?\d+)",
"x",
"y",
"z",
"12C/13C",
),
]

METADATA_SPHERICAL_RE_STR = [
(r"(.+)\n", "fname"),
(
r" (\d+\.)\s+Teff \[(.+)\]\.\s+Last iteration; yyyymmdd=\d+",
"teff",
"teff_units",
),
(r" (\d+\.\d+E\+\d+) Flux \[(.+)\]", "flux", "flux_units"),
(
r" (\d+.\d+E\+\d+) Surface gravity \[(.+)\]",
"surface_grav",
"surface_grav_units",
),
(
r" (\d+\.\d+)\W+Microturbulence parameter \[(.+)\]",
"microturbulence",
"microturbulence_units",
),
(
r"\s+(\d+\.\d+)\s+Mass \[(.+)\]",
"mass",
"mass_units",
),
(
r" (\+?\-?\d+.\d+) (\+?\-?\d+.\d+) Metallicity \[Fe\/H] and \[alpha\/Fe\]",
"feh",
"afe",
),
(
r" (\d+.\d+E\+\d\d) Radius \[(.+)\] at Tau",
"radius",
"radius_units",
),
(
r"\s+(\d+\.\d+(?:E[+-]?\d+)?) Luminosity \[(.+)\]",
"luminosity",
"luminosity_units",
),
(
r" (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+) are the convection parameters: alpha, nu, y and beta",
"conv_alpha",
"conv_nu",
"conv_y",
"conv_beta",
),
(
r" (0.\d+) (0.\d+) (\d.\d+E-\d+) are X, Y and Z, 12C\/13C=(\d+.?\d+)",
"x",
"y",
"z",
"12C/13C",
),
]
BYTES_THROUGH_METADATA = 550

if gzipped:
Expand Down
98 changes: 98 additions & 0 deletions stardis/io/model/marcs_regex_patterns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
METADATA_PLANE_PARALLEL_RE_STR = [
(r"(.+)\n", "fname"),
(
r" (\d+\.)\s+Teff \[(.+)\]\.\s+Last iteration; yyyymmdd=\d+",
"teff",
"teff_units",
),
(r" (\d+\.\d+E\+\d+) Flux \[(.+)\]", "flux", "flux_units"),
(
r" (\d+.\d+E\+\d+) Surface gravity \[(.+)\]",
"surface_grav",
"surface_grav_units",
),
(
r" (\d+\.\d+)\W+Microturbulence parameter \[(.+)\]",
"microturbulence",
"microturbulence_units",
),
(r" (\d+\.\d+)\s+(No mass for plane-parallel models)", "plane_parallel_mass"),
(
r" (\+?\-?\d+.\d+) (\+?\-?\d+.\d+) Metallicity \[Fe\/H] and \[alpha\/Fe\]",
"feh",
"afe",
),
(
r" (\d+\.\d+E\+00) (1 cm radius for plane-parallel models)",
"radius for plane-parallel model",
),
(r" (\d.\d+E-\d+) Luminosity \[(.+)\]", "luminosity", "luminosity_units"),
(
r" (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+) are the convection parameters: alpha, nu, y and beta",
"conv_alpha",
"conv_nu",
"conv_y",
"conv_beta",
),
(
r" (0.\d+) (0.\d+) (\d.\d+E-\d+) are X, Y and Z, 12C\/13C=(\d+.?\d+)",
"x",
"y",
"z",
"12C/13C",
),
]

METADATA_SPHERICAL_RE_STR = [
(r"(.+)\n", "fname"),
(
r" (\d+\.)\s+Teff \[(.+)\]\.\s+Last iteration; yyyymmdd=\d+",
"teff",
"teff_units",
),
(r" (\d+\.\d+E\+\d+) Flux \[(.+)\]", "flux", "flux_units"),
(
r" (\d+.\d+E\+\d+) Surface gravity \[(.+)\]",
"surface_grav",
"surface_grav_units",
),
(
r" (\d+\.\d+)\W+Microturbulence parameter \[(.+)\]",
"microturbulence",
"microturbulence_units",
),
(
r"\s+(\d+\.\d+)\s+Mass \[(.+)\]",
"mass",
"mass_units",
),
(
r" (\+?\-?\d+.\d+) (\+?\-?\d+.\d+) Metallicity \[Fe\/H] and \[alpha\/Fe\]",
"feh",
"afe",
),
(
r" (\d+.\d+E\+\d\d) Radius \[(.+)\] at Tau",
"radius",
"radius_units",
),
(
r"\s+(\d+\.\d+(?:E[+-]?\d+)?) Luminosity \[(.+)\]",
"luminosity",
"luminosity_units",
),
(
r" (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+) are the convection parameters: alpha, nu, y and beta",
"conv_alpha",
"conv_nu",
"conv_y",
"conv_beta",
),
(
r" (0.\d+) (0.\d+) (\d.\d+E-\d+) are X, Y and Z, 12C\/13C=(\d+.?\d+)",
"x",
"y",
"z",
"12C/13C",
),
]

0 comments on commit 28d0881

Please sign in to comment.