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

use string literals and remove delim_whitespace=True #192

Merged
merged 1 commit into from
Jun 17, 2024
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
26 changes: 13 additions & 13 deletions stardis/io/model/marcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,43 +167,43 @@ def read_marcs_metadata(fpath, gzipped=True):
"""

METADATA_RE_STR = [
("(.+)\\n", "fname"),
(r"(.+)\n", "fname"),
(
" (\d+\.)\s+Teff \[(.+)\]\.\s+Last iteration; yyyymmdd=\d+",
r" (\d+\.)\s+Teff \[(.+)\]\.\s+Last iteration; yyyymmdd=\d+",
"teff",
"teff_units",
),
(" (\d+\.\d+E\+\d+) Flux \[(.+)\]", "flux", "flux_units"),
(r" (\d+\.\d+E\+\d+) Flux \[(.+)\]", "flux", "flux_units"),
(
" (\d+.\d+E\+\d+) Surface gravity \[(.+)\]",
r" (\d+.\d+E\+\d+) Surface gravity \[(.+)\]",
"surface_grav",
"surface_grav_units",
),
(
" (\d+\.\d+)\W+Microturbulence parameter \[(.+)\]",
r" (\d+\.\d+)\W+Microturbulence parameter \[(.+)\]",
"microturbulence",
"microturbulence_units",
),
(" (\d+\.\d+)\s+(No mass for plane-parallel models)", "plane_parallel_mass"),
(r" (\d+\.\d+)\s+(No mass for plane-parallel models)", "plane_parallel_mass"),
(
" (\+?\-?\d+.\d+) (\+?\-?\d+.\d+) Metallicity \[Fe\/H] and \[alpha\/Fe\]",
r" (\+?\-?\d+.\d+) (\+?\-?\d+.\d+) Metallicity \[Fe\/H] and \[alpha\/Fe\]",
"feh",
"afe",
),
(
" (\d+\.\d+E\+00) (1 cm radius for plane-parallel models)",
r" (\d+\.\d+E\+00) (1 cm radius for plane-parallel models)",
"radius for plane-parallel model",
),
(" (\d.\d+E-\d+) Luminosity \[(.+)\]", "luminosity", "luminosity_units"),
(r" (\d.\d+E-\d+) Luminosity \[(.+)\]", "luminosity", "luminosity_units"),
(
" (\d+.\d+) (\d+.\d+) (\d+.\d+) (\d+.\d+) are the convection parameters: alpha, nu, y and beta",
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",
),
(
" (0.\d+) (0.\d+) (\d.\d+E-\d+) are X, Y and Z, 12C\/13C=(\d+.?\d+)",
r" (0.\d+) (0.\d+) (\d.\d+E-\d+) are X, Y and Z, 12C\/13C=(\d+.?\d+)",
"x",
"y",
"z",
Expand Down Expand Up @@ -276,15 +276,15 @@ def read_marcs_data(fpath, gzipped=True):
fpath,
skiprows=LINES_BEFORE_UPPER_TABLE,
nrows=MARCS_MODEL_SHELLS,
delim_whitespace=True,
sep=r"\s+",
index_col="k",
)
marcs_model_data_lower_split = pd.read_csv(
fpath,
skiprows=LINES_BEFORE_LOWER_TABLE,
nrows=MARCS_MODEL_SHELLS,
index_col="k",
sep="(?:\s+)|(?<=\+\d{2})(?=-)",
sep=r"(?:\s+)|(?<=\+\d{2})(?=-)",
engine="python",
)

Expand Down
2 changes: 1 addition & 1 deletion stardis/io/model/mesa.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def read_mesa_data(fpath, mesa_shells):
mesa_model = pd.read_csv(
fpath,
skiprows=ROWS_TO_SKIP,
delim_whitespace=True,
sep=r"\s+",
nrows=mesa_shells,
index_col=0,
comment="!",
Expand Down
Loading