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

Move to Pandas 1.x #1266

Merged
merged 6 commits into from
Aug 11, 2020
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
8 changes: 4 additions & 4 deletions docs/physics/plasma/plasma_plots/lte_ionization_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# Initializing a dataframe to store the ion populations and level populations for the different temperatures
ion_number_densities = pd.DataFrame(index=lte_plasma.ion_populations.index)
level_populations = pd.DataFrame(
index=lte_plasma.level_populations.ix[14, 1].index
index=lte_plasma.level_populations.loc[14, 1].index
)
t_rads = np.linspace(2000, 20000, 100)

Expand All @@ -54,19 +54,19 @@
ion_number_densities[t_rad] = ion_density

# normalizing the level_populations for Si II
current_level_population = lte_plasma.level_populations[0].ix[
current_level_population = lte_plasma.level_populations[0].loc[
14, 1
] / lte_plasma.ion_populations.get_value((14, 1), 0)

# normalizing with statistical weight
current_level_population /= atom_data.levels.ix[14, 1].g
current_level_population /= atom_data.levels.loc[14, 1].g

level_populations[t_rad] = current_level_population

ion_colors = ["b", "g", "r", "k"]

for ion_number in [0, 1, 2, 3]:
current_ion_density = ion_number_densities.ix[14, ion_number]
current_ion_density = ion_number_densities.loc[14, ion_number]
ax1.plot(
current_ion_density.index,
current_ion_density.values,
Expand Down
18 changes: 9 additions & 9 deletions docs/physics/plasma/plasma_plots/nebular_ionization_balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Initializing a dataframe to store the ion populations and level populations for the different temperatures
ion_number_densities = pd.DataFrame(index=nebular_plasma.ion_populations.index)
level_populations = pd.DataFrame(
index=nebular_plasma.level_populations.ix[14, 1].index
index=nebular_plasma.level_populations.loc[14, 1].index
)
t_rads = np.linspace(2000, 20000, 100)

Expand All @@ -53,18 +53,18 @@

# normalizing the level_populations for Si II
current_level_population = (
nebular_plasma.level_populations.ix[14, 1]
/ nebular_plasma.ion_populations.ix[14, 1]
nebular_plasma.level_populations.loc[14, 1]
/ nebular_plasma.ion_populations.loc[14, 1]
)
# normalizing with statistical weight
current_level_population /= atom_data.levels.ix[14, 1].g
current_level_population /= atom_data.levels.loc[14, 1].g

level_populations[t_rad] = current_level_population

ion_colors = ["b", "g", "r", "k"]

for ion_number in [0, 1, 2, 3]:
current_ion_density = ion_number_densities.ix[14, ion_number]
current_ion_density = ion_number_densities.loc[14, ion_number]
ax1.plot(
current_ion_density.index,
current_ion_density.values,
Expand Down Expand Up @@ -98,19 +98,19 @@

# normalizing the level_populations for Si II
current_level_population = (
nebular_plasma.level_populations.ix[14, 1]
/ nebular_plasma.ion_populations.ix[14, 1]
nebular_plasma.level_populations.loc[14, 1]
/ nebular_plasma.ion_populations.loc[14, 1]
)
# normalizing with statistical weight
current_level_population /= atom_data.levels.ix[14, 1].g
current_level_population /= atom_data.levels.loc[14, 1].g

level_populations[t_rad] = current_level_population

# Plotting the ion fractions

for ion_number in [0, 1, 2, 3]:
print("w=0.5")
current_ion_density = ion_number_densities.ix[14, ion_number]
current_ion_density = ion_number_densities.loc[14, ion_number]
ax1.plot(
current_ion_density.index,
current_ion_density.values,
Expand Down
2 changes: 1 addition & 1 deletion tardis/io/parsers/csvy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def load_csvy(fname):
yaml_dict = yaml.load("".join(yaml_lines[1:-1]), YAMLLoader)
try:
data = pd.read_csv(fname, skiprows=yaml_end_ind + 1)
except pd.io.common.EmptyDataError as e:
except pd.errors.EmptyDataError as e:
data = None

return yaml_dict, data
Expand Down
4 changes: 2 additions & 2 deletions tardis/plasma/properties/atomic.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ class ZetaData(BaseAtomicDataProperty):
outputs = ("zeta_data",)

def _filter_atomic_property(self, zeta_data, selected_atoms):
zeta_data["atomic_number"] = zeta_data.index.labels[0] + 1
zeta_data["ion_number"] = zeta_data.index.labels[1] + 1
zeta_data["atomic_number"] = zeta_data.index.codes[0] + 1
zeta_data["ion_number"] = zeta_data.index.codes[1] + 1
zeta_data = zeta_data[zeta_data.atomic_number.isin(selected_atoms)]
zeta_data_check = counter(zeta_data.atomic_number.values)
keys = np.array(list(zeta_data_check.keys()))
Expand Down
2 changes: 1 addition & 1 deletion tardis/plasma/properties/partition_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def _main_nlte_calculation(
)
else:
raise e
general_level_boltzmann_factor[i].ix[species] = (
general_level_boltzmann_factor[i].loc[species] = (
level_boltzmann_factor
* g.loc[species][0]
/ level_boltzmann_factor[0]
Expand Down
2 changes: 1 addition & 1 deletion tardis_env3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies:
- pip
- numpy=1.16
- scipy=1.5
- pandas=0.24
- pandas=1.0
- astropy=3
- numba=0.50
- numexpr
Expand Down