def test_proximal_join(self): s1 = Spectrum(name='s1', measurement=pd.Series([1, 2, 3, 4], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata={'gps_time_tgt': 1}) s2 = Spectrum(name='s2', measurement=pd.Series([10, 11, 12, 13], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata={'gps_time_tgt': 5}) s3 = Spectrum(name='s3', measurement=pd.Series([100, 200, 300, 400], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata={'gps_time_tgt': 10}) base = Collection(name='base', spectra=[s1, s2, s3]) s4 = Spectrum(name='s4', measurement=pd.Series([1, 2, 3, 4], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata={'gps_time_tgt': 2}) s5 = Spectrum(name='s5', measurement=pd.Series([10, 11, 12, 13], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata={'gps_time_tgt': 5}) s6 = Spectrum(name='s6', measurement=pd.Series([100, 200, 300, 400], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata={'gps_time_tgt': 9}) rover = Collection(name='rover', spectra=[s4, s5, s6]) proximal = proximal_join(base, rover) proximal_df_correct = pd.DataFrame( { 's4': [1.0, 1.0, 1.0, 1.0], 's5': [1.0, 1.0, 1.0, 1.0], 's6': [1.0, 1.0, 1.0, 1.0] }, index=pd.Index([1, 2, 3, 4], name='wavelength')) pdt.assert_frame_equal(proximal.data, proximal_df_correct)
def test_collection_data_with_meta(self): m1 = OrderedDict() m2 = OrderedDict() m3 = OrderedDict() for i, meta in enumerate([m1, m2, m3]): meta['file'] = 'f{}'.format(i) meta['instrument_type'] = 'asd' meta['integration_time'] = '15' meta['measurement_type'] = 'pct_reflect' meta['gps_time'] = (100 + i, 200 + i) meta['wavelength_range'] = (1, 4) s1 = Spectrum(name='s1', measurement=pd.Series([1, 2, 3, 4], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata=m1) s2 = Spectrum(name='s2', measurement=pd.Series([10, 11, 12, 13], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata=m2) s3 = Spectrum(name='s3', measurement=pd.Series([100, 200, 300, 400], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect'), metadata=m3) c1 = Collection(name='c1', spectra=[s1, s2, s3]) c1.data_with_meta()
def read_dir(self): directory = filedialog.askdirectory() if not directory: return self.collectionList.add_collection( Collection(name="collection" + str(self.collectionList.listbox.size()), directory=directory))
def setUp(self): # total 36 spectra self.c = Collection(name='For Groups') for a in ('A', 'B', 'C'): for b in ('a', 'b', 'c'): for c in ('0', '1'): for d in ('0001', '0002', '0003', '0004'): self.c.append(Spectrum('_'.join([a, b, c, d])))
def test_collection_assert_unique_name1(self): s1 = Spectrum(name='s1', measurement= pd.Series([1, 2, 3, 4], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect')) s2 = Spectrum(name='s1', measurement= pd.Series([1, 2, 3, 4], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect')) c1 = Collection(name='c1') c1.append(s1) self.assertRaises(AssertionError, c1.append, s2)
def test_collection_data_unstitched(self): s1 = Spectrum(name='s1', measurement=pd.Series([1, 2, 3, 4], index=pd.Index([1, 2, 3, 4], name='wavelength'), name='pct_reflect')) s2 = Spectrum(name='s2', measurement=pd.Series([10, 11, 12, 13], index=pd.Index([0.8, 2.2, 3.7, 5], name='wavelength'), name='pct_reflect')) s3 = Spectrum(name='s3', measurement=pd.Series([100, 200, 300, 400, 500], index=pd.Index([1, 2, 3, 3, 4], name='wavelength'), name='pct_reflect')) c1 = Collection(name='c1', spectra=[s1, s2, s3]) self.assertRaises(ValueError, lambda: c1.data) c1.stitch()
def read_test_data(): path = '~/data/specdal/aidan_data2/ASD' c = Collection("Test Collection", directory=path) for i in range(30): c.flag(c.spectra[i].name) return c