Skip to content

Commit

Permalink
the test exo-transmit files are incomplete!
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsavel committed Mar 21, 2024
1 parent 2f3601a commit 81fe4c8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
6 changes: 4 additions & 2 deletions src/cortecs/opac/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ def get_lams_and_opacities(self, file):
except:
pdb.set_trace()

def load(self, filename):
def load(self, filename, fullfile=True):
"""
Loads file.
Expand All @@ -415,7 +415,9 @@ def load(self, filename):

# and now make it log10
cross_section = np.log10(cross_section)
cross_section = cross_section.reshape(len(T), len(P), len(wl))

if fullfile: # only reshape if it's not a "test" file.
cross_section = cross_section.reshape(len(T), len(P), len(wl))

return wl, T, P, cross_section

Expand Down
39 changes: 15 additions & 24 deletions src/cortecs/tests/test_chunking.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
just do a few tests for chunking...
"""

import unittest
import os
import numpy as np
Expand All @@ -9,6 +10,8 @@


class TestIntegration(unittest.TestCase):
load_kwargs = {"fullfile": False}

opacity_file = os.path.abspath(".") + "/src/cortecs/tests/opacCH4_narrow_wl.dat"
first_file = os.path.abspath(".") + "/src/cortecs/tests/" + "opacCH4_narrow_wl0.dat"
second_file = (
Expand Down Expand Up @@ -43,12 +46,10 @@ def test_wls_of_each_created_file(self):
# now get the wavelengths of each file
opac_obj_ref = Opac(self.opacity_file, loader="exotransmit")
opac_obj0 = Opac(
self.first_file,
loader="exotransmit",
self.first_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
opac_obj1 = Opac(
self.second_file,
loader="exotransmit",
self.second_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
np.testing.assert_array_equal(
opac_obj_ref.wl, np.concatenate((opac_obj0.wl, opac_obj1.wl))
Expand All @@ -67,12 +68,10 @@ def test_vals_of_each_created_file(self):
# now get the wavelengths of each file
opac_obj_ref = Opac(self.opacity_file, loader="exotransmit")
opac_obj0 = Opac(
self.first_file,
loader="exotransmit",
self.first_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
opac_obj1 = Opac(
self.second_file,
loader="exotransmit",
self.second_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
# pdb.set_trace()
np.testing.assert_array_equal(
Expand All @@ -92,25 +91,21 @@ def test_add_overlap_wl_increase_or_same(self):

chunk_wavelengths(self.opacity_file, wav_per_chunk=2)
opac_obj0_orig = Opac(
self.first_file,
loader="exotransmit",
self.first_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
opac_obj1_orig = Opac(
self.second_file,
loader="exotransmit",
self.second_file, loader="exotransmit", load_kwargs=self.load_kwargs
)

add_overlap(self.file_base, v_max=0.0)

# now get the wavelengths of each file
opac_obj_ref = Opac(self.opacity_file, loader="exotransmit")
opac_obj0 = Opac(
self.first_file,
loader="exotransmit",
self.first_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
opac_obj1 = Opac(
self.second_file,
loader="exotransmit",
self.second_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
# pdb.set_trace()
self.assertTrue(
Expand All @@ -128,12 +123,10 @@ def add_overlap_with_single_overlap_point(self):

chunk_wavelengths(self.opacity_file, wav_per_chunk=2)
opac_obj0_orig = Opac(
self.first_file,
loader="exotransmit",
self.first_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
opac_obj1_orig = Opac(
self.second_file,
loader="exotransmit",
self.second_file, loader="exotransmit", load_kwargs=self.load_kwargs
)

# calculate the vmax so that one point is changed
Expand All @@ -146,12 +139,10 @@ def add_overlap_with_single_overlap_point(self):
# now get the wavelengths of each file
opac_obj_ref = Opac(self.opacity_file, loader="exotransmit")
opac_obj0 = Opac(
self.first_file,
loader="exotransmit",
self.first_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
opac_obj1 = Opac(
self.second_file,
loader="exotransmit",
self.second_file, loader="exotransmit", load_kwargs=self.load_kwargs
)
self.assertTrue(
len(opac_obj1.wl.min) == len(opac_obj0.wl.max())
Expand Down

0 comments on commit 81fe4c8

Please sign in to comment.