Skip to content

Commit

Permalink
Lint fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
knc6 committed Oct 4, 2024
1 parent 8b6da9b commit 8946203
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
13 changes: 8 additions & 5 deletions jarvis/analysis/solarefficiency/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
Please find more detailsin:
https://pubs.acs.org/doi/abs/10.1021/acs.chemmater.9b02166
"""

import numpy as np
import os
from scipy.interpolate import interp1d
from numpy import interp
import scipy.constants as constants

try:
from scipy.integrate import simps
except:
except Exception:
from scipy.integrate import simpson as simps

pass
import matplotlib.pyplot as plt

Expand Down Expand Up @@ -73,7 +76,7 @@ def calculate_SQ(
# units of W/(m**3), different than solar_spectra_irradiance!!! (This
# is intentional, it is for convenience)
blackbody_irradiance = (
2.0 * h * c ** 2 / (solar_spectra_wavelength_meters ** 5)
2.0 * h * c**2 / (solar_spectra_wavelength_meters**5)
) * (
1.0
/ (
Expand Down Expand Up @@ -113,7 +116,7 @@ def calculate_SQ(
)

bandgap_blackbody = (
(2.0 * h * c ** 2 / (bandgap_wavelength ** 5))
(2.0 * h * c**2 / (bandgap_wavelength**5))
* (
1.0
/ (
Expand Down Expand Up @@ -277,7 +280,7 @@ def slme(
# units of W/(m**3), different than solar_spectra_irradiance!!! (This
# is intentional, it is for convenience)
blackbody_irradiance = (
2.0 * h * c ** 2 / (solar_spectra_wavelength_meters ** 5)
2.0 * h * c**2 / (solar_spectra_wavelength_meters**5)
) * (
1.0
/ (
Expand All @@ -302,7 +305,7 @@ def slme(
# units of nm
material_wavelength_for_absorbance_data = (
(c * h_e) / (material_energy_for_absorbance_data + 0.00000001)
) * 10 ** 9
) * 10**9

# absorbance interpolation onto each solar spectrum wavelength

Expand Down
2 changes: 1 addition & 1 deletion jarvis/analysis/structure/spacegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

try:
import spglib
except Exception as exp:
except Exception:
# print(exp)
pass
# from numpy import gcd
Expand Down
28 changes: 18 additions & 10 deletions jarvis/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Set of useful utility functions."""

from collections import OrderedDict
from collections import defaultdict
from scipy import sparse
from scipy.sparse.linalg import spsolve
import random
Expand Down Expand Up @@ -338,7 +339,7 @@ def cos_formula(a, b, c):
def baseline_als(y, lam, p, niter=10):
"""
Adaptive Least Squares fitting for baseline correction
Parameters:
y: array_like
Input signal
Expand All @@ -348,32 +349,39 @@ def baseline_als(y, lam, p, niter=10):
Asymmetry
niter: int, optional
Number of iterations
Returns:
array_like
The estimated baseline
"""
L = len(y)
D = sparse.diags([1,-2,1],[0,-1,-2], shape=(L,L-2))
D = sparse.diags([1, -2, 1], [0, -1, -2], shape=(L, L - 2))
w = np.ones(L)
for i in range(niter):
W = sparse.spdiags(w, 0, L, L)
Z = W + lam * D.dot(D.transpose())
z = spsolve(Z, w*y)
w = p * (y > z) + (1-p) * (y < z)
z = spsolve(Z, w * y)
w = p * (y > z) + (1 - p) * (y < z)
return z

def recast_array(x_original = [],y_original = [],x_new = np.arange(0, 90, 1),tol=0.1):
x_original=np.array(x_original)


def recast_array(
x_original=[], y_original=[], x_new=np.arange(0, 90, 1), tol=0.1
):
x_original = np.array(x_original)
# Initialize the new y array with NaNs or a default value
y_new = np.full_like(x_new, 0, dtype=np.float64)

# Fill the corresponding bins
for x_val, y_val in zip(x_original, y_original):
closest_index = np.abs(x_new - x_val).argmin() # Find the closest x_new index
closest_index = np.abs(
x_new - x_val
).argmin() # Find the closest x_new index
y_new[closest_index] = y_val
#y_new[y_new<tol]=0
# y_new[y_new<tol]=0
return x_new, y_new


# def is_xml_valid(xsd="jarvisdft.xsd", xml="JVASP-1002.xml"):
# """Check if XML is valid."""
# xml_file = etree.parse(xml)
Expand Down
1 change: 1 addition & 0 deletions jarvis/db/figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ def get_wann_phonon(jid="JVASP-1002", factor=15.633302):
# Requires phonopy
from jarvis.io.phonopy.outputs import get_phonon_tb
from jarvis.io.vasp.outputs import Vasprun
from jarvis.io.wannier.outputs import WannierHam

fls = data("raw_files")

Expand Down

0 comments on commit 8946203

Please sign in to comment.