Exemple #1
0
def test_get_logger():
    test_logger = get_logger(__name__)
    assert test_logger.name == 'stixcore.util.tests.test_logging'
    assert test_logger.level == logging.WARNING

    test_logger = get_logger('another', level=logging.DEBUG)
    assert test_logger.name == 'another'
    assert test_logger.level == logging.DEBUG
Exemple #2
0
from stixcore.products.common import (
    _get_compression_scheme,
    _get_detector_mask,
    _get_energy_bins,
    _get_pixel_mask,
    _get_sub_spectrum_mask,
    get_min_uint,
    rebin_proportional,
)
from stixcore.products.product import Control, Data, EnergyChannelsMixin, GenericProduct
from stixcore.time import SCETime, SCETimeDelta, SCETimeRange
from stixcore.util.logging import get_logger

__all__ = ['QLProduct', 'LightCurve', 'Background', 'Spectra']

logger = get_logger(__name__, level=logging.WARNING)

QLNIX00405_off = 0.1


class QLProduct(GenericProduct, EnergyChannelsMixin):
    """Generic QL product class composed of control and data."""
    def __init__(self, *, service_type, service_subtype, ssid, control, data,
                 idb_versions=defaultdict(SCETimeRange), **kwargs):
        """Create a generic QL product composed of control and data.

        Parameters
        ----------
        service_type : `int`
            21
        service_subtype : `int`
Exemple #3
0
from stixcore.idb.idb import IDB
from stixcore.time import SCETime
from stixcore.util.logging import get_logger

# thread_lock = threading.Lock()

__all__ = ['IDBManager']

IDB_FILENAME = "idb.sqlite"
IDB_VERSION_PREFIX = "v"
IDB_VERSION_DELIM = "."
IDB_VERSION_HISTORY_FILE = "idbVersionHistory.json"

IDB_FORCE_VERSION_KEY = '__FORCE_VERSION__'

logger = get_logger(__name__, level=logging.DEBUG)


class IDBManager:
    """Manages IDB (definition of TM/TC packet structures) Versions and provides a IDB reader."""
    def __init__(self, data_root, force_version=None):
        """Create the manager for a given data path root.

        Parameters
        ----------
        data_root : `str` | `pathlib.Path`
            Path to the directory with all IDB versions
        force_version : `str` | `pathlib.Path`
            `pathlib.Path`: Path to a directory with a specific IDB version
            `str` : Version Label to a IDB version within the data_root directory
        """
Exemple #4
0
from stixcore.ephemeris.manager import Spice
from stixcore.idb.idb import IDB
from stixcore.idb.manager import IDBManager
from stixcore.time import SCETime
from stixcore.tmtc.parameter import CompressedParameter, EngineeringParameter, Parameter
from stixcore.tmtc.parser import parse_binary, parse_bitstream, parse_variable

__all__ = [
    'TMTC', 'SourcePacketHeader', 'TMDataHeader', 'TCDataHeader',
    'GenericPacket', 'TMPacket', 'TCPacket', 'GenericTMPacket',
    'PacketSequence', 'SequenceFlag'
]

from stixcore.util.logging import get_logger

logger = get_logger(__name__)

SOURCE_PACKET_HEADER_STRUCTURE = {
    'version': 'uint:3',
    'packet_type': 'uint:1',
    'header_flag': 'uint:1',
    'process_id': 'uint:7',
    'packet_category': 'uint:4',
    'sequence_flag': 'uint:2',
    'sequence_count': 'uint:14',
    'data_length': 'uint:16'
}

TM_DATA_HEADER_STRUCTURE = {
    'spare1': 'uint:1',
    'pus_version': 'uint:3',
Exemple #5
0
import logging
import warnings
from time import perf_counter
from pathlib import Path
from collections import defaultdict
from concurrent.futures import ProcessPoolExecutor

from sunpy.util.datatype_factory_base import NoMatchError

from stixcore.config.config import CONFIG
from stixcore.ephemeris.manager import Spice, SpiceKernelManager
from stixcore.io.fits.processors import FitsL1Processor
from stixcore.products import Product
from stixcore.util.logging import get_logger

logger = get_logger(__name__, level=logging.INFO)


class Level1:
    def __init__(self, source_dir, output_dir):
        self.source_dir = Path(source_dir)
        self.output_dir = Path(output_dir)
        self.level0_files = sorted(list(self.source_dir.rglob('*.fits')))
        self.processor = FitsL1Processor(self.output_dir)

    def process_fits_files(self, files=None):
        all_files = list()
        if files is None:
            files = self.level0_files

        product_types = defaultdict(list)