From 81fe4c8718e5965dfa0591e168b147eb2708ad5b Mon Sep 17 00:00:00 2001 From: arjunsavel Date: Thu, 21 Mar 2024 16:46:45 -0400 Subject: [PATCH] the test exo-transmit files are incomplete! --- src/cortecs/opac/io.py | 6 +++-- src/cortecs/tests/test_chunking.py | 39 ++++++++++++------------------ 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/cortecs/opac/io.py b/src/cortecs/opac/io.py index df59dcd..7532b5f 100644 --- a/src/cortecs/opac/io.py +++ b/src/cortecs/opac/io.py @@ -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. @@ -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 diff --git a/src/cortecs/tests/test_chunking.py b/src/cortecs/tests/test_chunking.py index f1c072b..76b41b4 100644 --- a/src/cortecs/tests/test_chunking.py +++ b/src/cortecs/tests/test_chunking.py @@ -1,6 +1,7 @@ """ just do a few tests for chunking... """ + import unittest import os import numpy as np @@ -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 = ( @@ -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)) @@ -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( @@ -92,12 +91,10 @@ 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) @@ -105,12 +102,10 @@ def test_add_overlap_wl_increase_or_same(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() self.assertTrue( @@ -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 @@ -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())