# Path: gammacat/utils.py
# class TableProcessor:
#     """Shared code between SED and Lightcurve processing classes."""
#     resource_type = None
# 
#     def __init__(self, table, resource):
#         self.table = table
#         self.resource = resource
# 
#     @classmethod
#     def read(cls, filename, format='ascii.ecsv'):
#         log.debug('Reading {}'.format(filename))
#         table = Table.read(str(filename), format=format)
#         resource = cls._read_resource_info(table, filename)
#         return cls(table=table, resource=resource)
# 
#     @classmethod
#     def _read_resource_info(cls, table, location):
#         m = table.meta
#         return GammaCatResource(
#             source_id=m['source_id'],
#             reference_id=m['reference_id'],
#             file_id=m.get('file_id', -1),
#             type=cls.resource_type,
#             location=location,
#         )
# 
#     def validate_table_colnames(self, expected_colnames):
#         unexpected_colnames = sorted(set(self.table.colnames) - set(expected_colnames))
#         if unexpected_colnames:
#             log.error(
#                 'Resource {} contains invalid columns: {}'
#                 ''.format(self.resource, unexpected_colnames)
#             )
# 
#     def make_table_columns_uniform(self, col_specs):
#         """Make column units and description uniform."""
#         for col_spec in col_specs:
#             name = col_spec['name']
#             if name in self.table.colnames:
#                 if 'unit' in col_spec:
#                     self.table[name] = self.table[name].quantity.to(col_spec['unit'])
# 
#                 self.table[name].description = col_spec['description']
# 
#     def validate_input_meta(self):
#         meta = self.table.meta
# 
#         missing = sorted(set(self.required_meta_keys) - set(meta.keys()))
#         if missing:
#             log.error('Resource {} contains missing meta keys: {}'.format(self.resource, missing))
# 
#         extra = sorted(set(meta.keys()) - set(self.allowed_meta_keys))
#         if extra:
#             log.error('Resource {} contains extra meta keys: {}'.format(self.resource, extra))
# 
#         if ('comments' in meta) and not isinstance(meta['comments'], str):
#             log.error('Resource {} contains invalid meta key comments (should be str): {}'
#                       ''.format(self.resource, meta['comments']))


import logging
from .utils import TableProcessor
# Licensed under a 3-clause BSD style license - see LICENSE.rst

__all__ = [
    'SED',
]

log = logging.getLogger(__name__)



# Path: gammacat/utils.py
# class TableProcessor:
#     """Shared code between SED and Lightcurve processing classes."""
#     resource_type = None
# 
#     def __init__(self, table, resource):
#         self.table = table
#         self.resource = resource
# 
#     @classmethod
#     def read(cls, filename, format='ascii.ecsv'):
#         log.debug('Reading {}'.format(filename))
#         table = Table.read(str(filename), format=format)
#         resource = cls._read_resource_info(table, filename)
#         return cls(table=table, resource=resource)
# 
#     @classmethod
#     def _read_resource_info(cls, table, location):
#         m = table.meta
#         return GammaCatResource(
#             source_id=m['source_id'],
#             reference_id=m['reference_id'],
#             file_id=m.get('file_id', -1),
#             type=cls.resource_type,
#             location=location,
#         )
# 
#     def validate_table_colnames(self, expected_colnames):
#         unexpected_colnames = sorted(set(self.table.colnames) - set(expected_colnames))
#         if unexpected_colnames:
#             log.error(
#                 'Resource {} contains invalid columns: {}'
#                 ''.format(self.resource, unexpected_colnames)
#             )
# 
#     def make_table_columns_uniform(self, col_specs):
#         """Make column units and description uniform."""
#         for col_spec in col_specs:
#             name = col_spec['name']
#             if name in self.table.colnames:
#                 if 'unit' in col_spec:
#                     self.table[name] = self.table[name].quantity.to(col_spec['unit'])
# 
#                 self.table[name].description = col_spec['description']
# 
#     def validate_input_meta(self):
#         meta = self.table.meta
# 
#         missing = sorted(set(self.required_meta_keys) - set(meta.keys()))
#         if missing:
#             log.error('Resource {} contains missing meta keys: {}'.format(self.resource, missing))
# 
#         extra = sorted(set(meta.keys()) - set(self.allowed_meta_keys))
#         if extra:
#             log.error('Resource {} contains extra meta keys: {}'.format(self.resource, extra))
# 
#         if ('comments' in meta) and not isinstance(meta['comments'], str):
#             log.error('Resource {} contains invalid meta key comments (should be str): {}'
#                       ''.format(self.resource, meta['comments']))


# Path: gammacat/sed.py
import logging
from .utils import TableProcessor

# Licensed under a 3-clause BSD style license - see LICENSE.rst

__all__ = [
    'SED',
]

log = logging.getLogger(__name__)



class SED(TableProcessor):