Example #1
0
def test_save_persister():
    paths.build('_dev')
    dvc = DVC(bind=False)
    dvc.db.connect()

    per = DVCPersister(dvc=dvc)

    run_spec = AutomatedRunSpec()
    run_spec.labnumber = '10001'
    run_spec.project = 'Test'

    arar = ArArAge()
    arar.isotopes['Ar40'] = Isotope(xs=[1, 2, 3], ys=[1, 2, 3],
                                    name='Ar40', detector='H1')
    sd = {}
    dd = {'H1': 100}
    gd = {'H1': 1.021}
    per_spec = PersistenceSpec(run_spec=run_spec,
                               arar_age=arar,
                               spec_dict=sd,
                               defl_dict=dd,
                               gains=gd,
                               positions=[1, ],
                               experiment_queue_name='testexp.txt',
                               measurement_name='jan_unknown.py',
                               extraction_name='foo.py')

    per.per_spec_save(per_spec)
Example #2
0
    def main():
        from pychron.paths import paths
        paths.build('_dev')
        from pychron.core.helpers.logger_setup import logging_setup
        from pychron.experiment.automated_run.spec import AutomatedRunSpec
        logging_setup('dvcdb')
        from pychron.dvc.dvc_database import DVCDatabase
        from itertools import groupby
        db = DVCDatabase(kind='mysql', host='localhost', username='******', name='pychronmeta', password='******')
        db.connect()
        identifiers = ['63290', '63291']
        runs = [AutomatedRunSpec(identifier='63290', repository_identifier='Cather_McIntoshd')]
        cr = ConflictResolver()
        experiments = {}
        cr.available_ids = db.get_repository_identifiers()
        eas = db.get_associated_repositories(identifiers)
        for idn, exps in groupby(eas, key=lambda x: x[1]):
            experiments[idn] = [e[0] for e in exps]
        conflicts = []
        for ai in runs:
            identifier = ai.identifier
            es = experiments[identifier]
            if ai.repository_identifier not in es:
                conflicts.append((ai, es))
        if conflicts:
            cr.add_conflicts('Foo', conflicts)

        if cr.conflicts:

            info = cr.edit_traits(kind='livemodal')
            if info.result:
                cr.apply()
Example #3
0
def initialize_version(appname, debug):
    root = os.path.dirname(__file__)

    if not debug:
        add_eggs(root)
    else:
        build_sys_path()

    # from pychron.environment.util import get_environment
    # env = get_environment(appname)
    from pychron.envisage.user_login import get_user
    args = get_user()
    if args is None:
        return False
    else:
        user, env = args

    if not env:
        return False

    set_application_home(appname, env)

    from pychron.paths import paths
    logger.debug('using Pychron environment: {}'.format(env))
    paths.build(env)

    from configparser import ConfigParser, NoSectionError
    cp = ConfigParser()
    pref_path = os.path.join(ETSConfig.application_home, 'preferences.ini')
    cp.read(pref_path)
    try:
        cp.set('pychron.general', 'environment', env)
    except NoSectionError:
        cp.add_section('pychron.general')
        cp.set('pychron.general', 'environment', env)

    root = os.path.dirname(pref_path)
    if not os.path.isdir(root):
        os.mkdir(root)

    with open(pref_path, 'w') as wfile:
        cp.write(wfile)

    # build globals
    build_globals(user, debug)

    from pychron.core.helpers.logger_setup import logging_setup
    from pychron.paths import build_directories

    # build directories
    build_directories()
    paths.write_defaults()

    # setup logging. set a basename for log files and logging level
    logging_setup('pychron', level='DEBUG')

    from pychron.core.helpers.exception_helper import set_exception_handler
    set_exception_handler()

    return env
Example #4
0
def run():
    import argparse
    import os

    paths.build(os.getenv('PYCHRON_ROOT'))

    logging_setup('furnace_firmware', use_archiver=False)
    parser = argparse.ArgumentParser(description='Run NMGRL Furnace Firmware')

    # parser.add_argument('--host',
    #                     type=str,
    #                     default='127.0.0.1',
    #                     help='host')

    parser.add_argument('--port',
                        type=int,
                        default=4567,
                        help='TCP port to listen')

    # parser.add_argument('--debug',
    #                     action='store_true',
    #                     default=False,
    #                     help='run in debug mode')

    fm = Firmware()
    fm.bootstrap(**vars(parser.parse_args()))
Example #5
0
def suite():
    # set env. variables
    os.environ['MassSpecDBVersion'] = '16'

    from pychron.paths import paths
    paths.build('_dev')

    if use_logger:
        from pychron.core.helpers.logger_setup import logging_setup
        logging_setup('unittests')

    from pychron.canvas.canvas2D.tests.calibration_item import CalibrationObjectTestCase
    from pychron.stage.tests.stage_map import StageMapTestCase, \
        TransformTestCase
    from pychron.entry.tests.sample_loader import SampleLoaderTestCase
    from pychron.core.helpers.tests.floatfmt import FloatfmtTestCase
    from pychron.processing.tests.analysis_modifier import AnalysisModifierTestCase
    from pychron.experiment.tests.backup import BackupTestCase
    from pychron.core.xml.tests.xml_parser import XMLParserTestCase
    from pychron.entry.tests.analysis_loader import XLSAnalysisLoaderTestCase
    from pychron.entry.tests.irradiation_loader import XLSIrradiationLoaderParseTestCase, \
        XLSIrradiationLoaderLoadTestCase
    from pychron.entry.tests.massspec_irrad_export import MassSpecIrradExportTestCase
    from pychron.core.regression.tests.regression import OLSRegressionTest, MeanRegressionTest, \
        FilterOLSRegressionTest, OLSRegressionTest2
    from pychron.experiment.tests.frequency_test import FrequencyTestCase, FrequencyTemplateTestCase
    from pychron.experiment.tests.position_regex_test import XYTestCase
    from pychron.experiment.tests.renumber_aliquot_test import RenumberAliquotTestCase

    from pychron.external_pipette.tests.external_pipette import ExternalPipetteTestCase
    from pychron.processing.tests.plateau import PlateauTestCase
    from pychron.processing.tests.ratio import RatioTestCase
    from pychron.pyscripts.tests.extraction_script import WaitForTestCase
    from pychron.pyscripts.tests.measurement_pyscript import InterpolationTestCase, DocstrContextTestCase
    from pychron.experiment.tests.conditionals import ConditionalsTestCase, ParseConditionalsTestCase
    from pychron.experiment.tests.identifier import IdentifierTestCase
    from pychron.experiment.tests.comment_template import CommentTemplaterTestCase

    loader = unittest.TestLoader()
    suite = unittest.TestSuite()

    tests = (CalibrationObjectTestCase, StageMapTestCase, TransformTestCase,
             SampleLoaderTestCase, AnalysisModifierTestCase, BackupTestCase,
             MassSpecIrradExportTestCase, XMLParserTestCase,
             XLSIrradiationLoaderLoadTestCase,
             XLSIrradiationLoaderParseTestCase, XLSAnalysisLoaderTestCase,
             RatioTestCase, InterpolationTestCase, DocstrContextTestCase,
             OLSRegressionTest, OLSRegressionTest2, MeanRegressionTest,
             FilterOLSRegressionTest, PlateauTestCase, ExternalPipetteTestCase,
             WaitForTestCase, XYTestCase, FrequencyTestCase,
             FrequencyTemplateTestCase, RenumberAliquotTestCase,
             ConditionalsTestCase, ParseConditionalsTestCase,
             IdentifierTestCase, CommentTemplaterTestCase, FloatfmtTestCase)

    for t in tests:
        suite.addTest(loader.loadTestsFromTestCase(t))

    return suite
Example #6
0
def main():
    paths.build('_dev')

    global log
    if not log:
        logging_setup('heapy')
        log = True

    return run()
Example #7
0
def main():
    paths.build('_dev')

    global log
    if not log:
        logging_setup('heapy')
        log = True

    return run()
Example #8
0
def initialize_version(appname, debug):
    root = os.path.dirname(__file__)

    if not debug:
        add_eggs(root)
    else:
        build_sys_path()

    # can now use pychron.
    from pychron.paths import paths

    # paths.bundle_root = root
    # if '-' in setup_ver:
    # setup_ver = setup_ver.split('-')[0]

    from pychron.envisage.user_login import get_user

    user = get_user()
    if not user:
        logger.info('user login failed')
        os._exit(0)

    if appname.startswith('py'):
        appname = appname[2:]

    pref_path = os.path.join(paths.base, '.enthought',
                             'pychron.{}.application.{}'.format(appname, user),
                             'preferences.ini')

    from ConfigParser import ConfigParser

    cp = ConfigParser()
    cp.read(pref_path)

    try:
        proot = cp.get('pychron.general', 'root_dir')
    except BaseException:
        proot = '/Users/ross/Pychron'

    paths.build(proot)

    # build globals
    build_globals(debug)

    from pychron.core.helpers.logger_setup import logging_setup
    from pychron.paths import build_directories

    # build directories
    build_directories()

    # setup logging. set a basename for log files and logging level
    logging_setup('pychron', level='DEBUG')

    return user
Example #9
0
def get_db():
    conn = dict(host=os.environ.get('ARGONSERVER_HOST'),
                username='******',  # os.environ.get('ARGONSERVER_DB_USER'),
                password=os.environ.get('ARGONSERVER_DB_PWD'),
                kind='mysql')

    paths.build('~/PychronDev')
    meta_name = 'NMGRLMetaData'
    dvc = DVC(bind=False,
              organization='NMGRLData',
              meta_repo_name=meta_name)
    paths.meta_root = os.path.join(paths.dvc_dir, dvc.meta_repo_name)
    dvc.db.trait_set(**conn)
    if not dvc.initialize():
        warning(None, 'Failed to initialize DVC')
        return

    dvc.meta_repo.smart_pull()
    return dvc
Example #10
0
def get_dvc():
    conn = dict(
        host=os.environ.get('ARGONSERVER_HOST'),
        username='******',  # os.environ.get('ARGONSERVER_DB_USER'),
        password=os.environ.get('ARGONSERVER_DB_PWD'),
        name='pychrondvc',
        kind='mysql')

    paths.build('~/PychronDev')
    meta_name = 'NMGRLMetaData'
    dvc = DVC(bind=False, organization='NMGRLData', meta_repo_name=meta_name)
    paths.meta_root = os.path.join(paths.dvc_dir, dvc.meta_repo_name)
    dvc.db.trait_set(**conn)
    if not dvc.initialize():
        warning(None, 'Failed to initialize DVC')
        return

    dvc.meta_repo.smart_pull()
    return dvc
Example #11
0
    def main():
        from pychron.paths import paths
        paths.build('_dev')
        from pychron.core.helpers.logger_setup import logging_setup
        from pychron.experiment.automated_run.spec import AutomatedRunSpec
        logging_setup('dvcdb')
        from pychron.dvc.dvc_database import DVCDatabase
        from itertools import groupby
        db = DVCDatabase(kind='mysql',
                         host='localhost',
                         username='******',
                         name='pychronmeta',
                         password='******')
        db.connect()
        identifiers = ['63290', '63291']
        runs = [
            AutomatedRunSpec(identifier='63290',
                             repository_identifier='Cather_McIntoshd')
        ]
        cr = ConflictResolver()
        experiments = {}
        with db.session_ctx():
            cr.available_ids = db.get_repository_identifiers()
            eas = db.get_associated_repositories(identifiers)
            for idn, exps in groupby(eas, key=lambda x: x[1]):
                experiments[idn] = [e[0] for e in exps]
            conflicts = []
            for ai in runs:
                identifier = ai.identifier
                es = experiments[identifier]
                if ai.repository_identifier not in es:
                    conflicts.append((ai, es))
            if conflicts:
                cr.add_conflicts('Foo', conflicts)

        if cr.conflicts:

            info = cr.edit_traits(kind='livemodal')
            if info.result:
                cr.apply()
Example #12
0
def build_version(ver=None, setup_ver=None, debug=False):
    if ver is None:
        ver = ""

    if setup_ver is None:
        setup_ver = ""

    root = os.path.dirname(__file__)

    if not debug:
        add_eggs(root)
    else:
        build_sys_path(ver, root)

    # can now use pychron.
    from pychron.paths import paths

    paths.bundle_root = root
    if "-" in setup_ver:
        setup_ver = setup_ver.split("-")[0]
    paths.build(setup_ver)

    # build globals
    build_globals(debug)
Example #13
0
def build_version(ver=None, setup_ver=None, debug=False):
    if ver is None:
        ver = ''

    if setup_ver is None:
        setup_ver = ''

    root = os.path.dirname(__file__)

    if not debug:
        add_eggs(root)
    else:
        build_sys_path(ver, root)

    # can now use pychron.
    from pychron.paths import paths

    paths.bundle_root = root
    if '-' in setup_ver:
        setup_ver = setup_ver.split('-')[0]
    paths.build(setup_ver)

    # build globals
    build_globals(debug)
Example #14
0
#         v = View(Item('records', show_label=False,
#                       editor=TabularEditor(adapter=SensitivityAdapter(),
#                                            operations=['edit'],
#                                            editable=True,
#                                            )
#                       ),
#
#                  HGroup(Item('add_button', show_label=False),
#                         Item('save_button', show_label=False)),
#                  resizable=True,
#                  width=500,
#                  height=200,
#                  title='Sensitivity Table'
#                  )
#         return v


class SensitivitySelector(SensitivityEntry):
    pass


if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup

    paths.build('_experiment')

    logging_setup('runid')
    m = SensitivityEntry()
    m.configure_traits()
# ============= EOF =============================================
Example #15
0
#        '''
#        v = View()
#        for a in self._get_axes():
#
#            a.load_parameters_from_device()

#        v = super(AerotechMotionControllerManager, self).traits_view()
#        return v

    def _motion_controller_default(self):
        a = AerotechMotionController(name='unidex')

        return a

    def initialize(self, *args, **kw):
        self.motion_controller.bootstrap()
        return True

if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup
    logging_setup('amc')
    globalv.show_infos = False
    globalv.show_warnings = False
    paths.build('_experiment')

    amc = AerotechMotionControllerManager()
    amc.bootstrap()

    amc.configure_traits()
# ============= EOF ====================================
Example #16
0
def main1():
    from random import random

    # from pychron.paths import paths

    paths.build('_dev')

    # def add_runs(c, e):
    # class Spec():
    #         def __init__(self, record_id):
    #             self.runid = record_id
    #             # self.mass_spectrometer = 'jan'
    #             # self.extract_device = 'LF'
    #             self.analysis_timestamp = datetime.now()
    #             self.state = choice(['Finished', 'Canceled', 'Failed'])
    #             self.analysis_type = "unknown"
    #             self.sample = "FC-2"
    #             self.extract_value = random() * 2
    #             self.extract_units = 'watts'
    #             self.duration = randint(100, 200)
    #             self.cleanup = randint(100, 200)
    #             self.position = randint(0, 100)
    #             self.comment = "Test comment"
    #             self.material = "sanidine"
    #             self.project = "Monitor"
    #             self.measurement_script = 'unknown400_180'
    #             self.extraction_script = 'sniffair_x1'
    #             self.post_measurement_script = 'pump_spectrometer'
    #             self.post_equilibration_script = 'pump_extraction_line'
    #
    #     class Run():
    #         def __init__(self, *args, **kw):
    #             self.spec = Spec(*args, **kw)
    #
    #     for i in range(6):
    #         c.add_run(Run('20016-{:02d}'.format(i + 1)), e)
    #
    # def add_experiment(c):
    #     class Exp():
    #         def __init__(self, name, user, status):
    #             self.name = name
    #             self.username = user
    #             spec = choice(('Jan','Obama'))
    #             self.spectrometer = spec
    #             self.mass_spectrometer = spec
    #             self.extract_device = choice(('Fusions CO2', 'Fusions Diode'))
    #             self.status = status
    #             self.starttime = datetime.now()
    #
    #     e = Exp('Current Experiment', 'foobar', 'Running')
    #     c.add_experiment(e)
    #     return e
    #
    # def update_status(c):
    #     c.update_status(Error='Error big time')
    #     c.update_status(Message='This is a long message',
    #                     ShortMessage='This is a short message')

    def add_measurements(c):
        for i in range(100):
            c.add_measurement('AirPressure', 'pneumatics', random(), 'PSI')
            c.add_measurement('Environmental', 'temperature', random() * 2 + 70,
                              'C')
            c.add_measurement('Environmental', 'humidity', random() * 5 + 50,
                              '%')

            time.sleep(1)

    logging_setup('labspyclient', use_archiver=False)
    # c = LabspyClient(bind=False, host='129.138.12.138', port=27017)
    # c = MeteorLabspyClient(bind=False, host='localhost', port=3001)
    # # update_state(c)
    # for i in range(10):
    # add_device(c)
    # time.sleep(1)

    clt = LabspyClient(bind=False)
    clt.db.host = 'localhost'
    clt.db.username = os.environ.get('DB_USER')
    clt.db.password = os.environ.get('DB_PWD')
    clt.db.name = 'labspy'
    clt.test_connection()

    # set status
    # update_status(clt)

    # measurements
    add_measurements(clt)
Example #17
0
def suite():
    # set env. variables
    os.environ['MassSpecDBVersion'] = '16'

    from pychron.paths import paths
    paths.build('_dev')

    if use_logger:
        from pychron.core.helpers.logger_setup import logging_setup
        logging_setup('unittests')

    # Canvas
    from pychron.canvas.canvas2D.tests.calibration_item import CalibrationObjectTestCase

    # Core
    from pychron.core.tests.spell_correct import SpellCorrectTestCase
    from pychron.core.tests.filtering_tests import FilteringTestCase
    from pychron.core.stats.tests.peak_detection_test import MultiPeakDetectionTestCase
    from pychron.core.helpers.tests.floatfmt import FloatfmtTestCase
    from pychron.core.helpers.tests.strtools import CamelCaseTestCase
    from pychron.core.xml.tests.xml_parser import XMLParserTestCase
    from pychron.core.regression.tests.regression import OLSRegressionTest, MeanRegressionTest, \
        FilterOLSRegressionTest, OLSRegressionTest2, TruncateRegressionTest, ExpoRegressionTest, ExpoRegressionTest2

    # DataMapper
    from pychron.data_mapper.tests.usgs_vsc_file_source import USGSVSCFileSourceUnittest, \
        USGSVSCIrradiationSourceUnittest
    from pychron.data_mapper.tests.nu_file_source import NuFileSourceUnittest
    from pychron.data_mapper.tests.nmgrl_legacy_source import NMGRLLegacySourceUnittest

    # Experiment
    from pychron.experiment.tests.repository_identifier import ExperimentIdentifierTestCase
    from pychron.experiment.tests.peak_hop_parse import PeakHopYamlCase1
    from pychron.experiment.tests.peak_hop_parse import PeakHopYamlCase2
    from pychron.experiment.tests.backup import BackupTestCase
    from pychron.experiment.tests.peak_hop_parse import PeakHopTxtCase
    from pychron.experiment.tests.duration_tracker import DurationTrackerTestCase
    from pychron.experiment.tests.frequency_test import FrequencyTestCase, FrequencyTemplateTestCase
    from pychron.experiment.tests.position_regex_test import XYTestCase
    from pychron.experiment.tests.renumber_aliquot_test import RenumberAliquotTestCase
    from pychron.experiment.tests.conditionals import ConditionalsTestCase, ParseConditionalsTestCase
    from pychron.experiment.tests.identifier import IdentifierTestCase
    from pychron.experiment.tests.comment_template import CommentTemplaterTestCase

    # ExternalPipette
    from pychron.external_pipette.tests.external_pipette import ExternalPipetteTestCase

    # Processing
    from pychron.processing.tests.plateau import PlateauTestCase
    from pychron.processing.tests.ratio import RatioTestCase
    from pychron.processing.tests.age_converter import AgeConverterTestCase

    # Pyscripts
    from pychron.pyscripts.tests.extraction_script import WaitForTestCase
    from pychron.pyscripts.tests.measurement_pyscript import InterpolationTestCase, DocstrContextTestCase

    # Spectrometer
    from pychron.spectrometer.tests.mftable import MFTableTestCase, DiscreteMFTableTestCase
    from pychron.spectrometer.tests.integration_time import IntegrationTimeTestCase

    from pychron.stage.tests.stage_map import StageMapTestCase, TransformTestCase

    loader = unittest.TestLoader()
    suite = unittest.TestSuite()

    tests = (
        # Canvas
        CalibrationObjectTestCase,

        # Core
        SpellCorrectTestCase,
        FilteringTestCase,
        MultiPeakDetectionTestCase,
        FloatfmtTestCase,
        CamelCaseTestCase,
        RatioTestCase,
        XMLParserTestCase,
        OLSRegressionTest,
        MeanRegressionTest,
        ExpoRegressionTest,
        ExpoRegressionTest2,
        FilterOLSRegressionTest,
        OLSRegressionTest2,
        TruncateRegressionTest,

        # DataMapper
        USGSVSCFileSourceUnittest,
        USGSVSCIrradiationSourceUnittest,
        NuFileSourceUnittest,
        NMGRLLegacySourceUnittest,

        # Experiment
        ExperimentIdentifierTestCase,
        PeakHopYamlCase1,
        PeakHopYamlCase2,
        BackupTestCase,
        PeakHopTxtCase,
        DurationTrackerTestCase,
        FrequencyTestCase,
        FrequencyTemplateTestCase,
        XYTestCase,
        RenumberAliquotTestCase,
        ConditionalsTestCase,
        ParseConditionalsTestCase,
        IdentifierTestCase,
        CommentTemplaterTestCase,

        # ExternalPipette
        ExternalPipetteTestCase,

        # Processing
        PlateauTestCase,
        RatioTestCase,
        AgeConverterTestCase,

        # Pyscripts
        WaitForTestCase,
        InterpolationTestCase,
        DocstrContextTestCase,

        # Spectrometer
        MFTableTestCase,
        DiscreteMFTableTestCase,
        IntegrationTimeTestCase,

        # Stage
        StageMapTestCase, TransformTestCase)

    for t in tests:
        suite.addTest(loader.loadTestsFromTestCase(t))

    return suite
Example #18
0
# ==============================================================================
#    getters
# ==============================================================================

    def get_powermaps(self, **kw):
        return self._retrieve_items(PowerMapTable)
#        return self._get_items(PowerMapTable, globals(), **kw)

# =============================================================================
#   adder
# =============================================================================
    def add_powermap(self, **kw):
        b = PowerMapTable(**kw)
        self._add_item(b)
#        b = self._add_timestamped_item(PowerMapTable, **kw)
        return b

if __name__ == '__main__':
    paths.build('_diode')
    db = PowerMapAdapter(name=paths.powermap_db,
                         kind='sqlite')
    db.connect()

    dbs = PowerMapSelector(db=db)
    dbs.load_recent()
    dbs.configure_traits()


# ============= EOF =============================================
Example #19
0
                               fontsize=12,
                               fontsize_name='fontsize',
                               wrap=False,
                               tab_width=15)

        v = View(
            VGroup(
                VGroup(grp, label='Editor'),
                VGroup(UItem('object.text', editor=teditor, style='custom'),
                       label='Text')),
            # toolbar=ToolBar(),
            width=690,
            title=self.title,
            buttons=['OK', save_action, save_as_acion],
            resizable=True)
        return v


if __name__ == '__main__':
    root = os.path.join(os.path.expanduser('~'), 'PychronDev')
    paths.build(root)
    m = HopEditorModel()
    m.detectors = ['H2', 'H1', 'CDD']
    # m.open()
    m.new()
    h = HopEditorView(model=m)
    # m.new()
    h.configure_traits()

# ============= EOF =============================================
Example #20
0
                          title=self.title)
        return v

    def _measurement_script_default(self):
        s = Script(label='measurement')
        return s

    def _extraction_script_default(self):
        s = Script(label='extraction')
        return s


if __name__ == '__main__':
    from pychron.paths import paths

    paths.build('~/PychronDev')
    af = BulkRunFixer()


    class Run:
        extraction_script = 'Foo'
        measurement_script = 'Bar'
        analysis_type = 'unknown'


    a = Run()
    a.analysis_type = 'air'
    b = Run()
    b.analysis_type = 'blank'
    c = Run()
    runs = [a, b, c]
Example #21
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

from pychron.paths import paths

paths.build('dev')

# ============= enthought library imports =======================
from traits.api import HasTraits, Str, Int, Bool, Any, Float, Property, on_trait_change, Instance, Button
from traitsui.api import View, UItem, Item, HGroup, VGroup
# ============= standard library imports ========================
# ============= local library imports  ==========================
from traitsui.handler import Handler
from pychron.dvc.dvc import DVC
from pychron.graph.stacked_regression_graph import StackedRegressionGraph
from pychron.loggable import Loggable


class KlassHandler(Handler):
    def object_good_button_changed(self, info):
        info.object.klass = 1
Example #22
0
from pychron.globals import globalv
from pychron.core.ui import set_toolkit

set_toolkit("qt4")

from pychron.paths import paths

paths.build("_unittest")
# build_directories(paths)

from pychron.core.helpers.logger_setup import logging_setup
from pychron.lasers.laser_managers.fusions_diode_manager import FusionsDiodeManager

logging_setup("arar")
import unittest

globalv.ignore_connection_warnings = True


class Diode(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.manager = FusionsDiodeManager()
        cls.manager.temperature_controller.bootstrap()

    def test_pid_bins_first(self):
        temp = 300
        pd = self.manager._get_pid_bin(temp)
        self.assertEqual(pd, [0.0, 0.0, 0.0])

    def test_pid_bins(self):
Example #23
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

# ============= enthought library imports =======================
import os

from pychron.paths import paths

# ============= standard library imports ========================
# ============= local library imports  ==========================
paths.build('_test')


def launch_device(name, path):
    print 'Launching: {}'.format(name)
    print 'Config File: {}'.format(path)

    from pychron.hardware.pid_controller import DevelopmentPidController

    klass = DevelopmentPidController

    dev = klass(name=name, config_path=path)
    dev.bootstrap()
    dev.setup_scan()
    dev.start_scan()
    print dev
Example #24
0
from pychron.hardware.core.data_helper import make_bitarray
'''
    National Control Devices
    
   http://www.controlanything.com/ 
   
   The Complete ProXR Command Set:
   http://www.controlanything.com/Relay/Device/A0010
   http://assets.controlanything.com/manuals/ProXR.pdf
'''


from pychron.paths import paths
from pychron.core.helpers.logger_setup import logging_setup
logging_setup('prox')
paths.build('_prox')

#============= enthought library imports =======================
#============= standard library imports ========================
#============= local library imports  ==========================
from pychron.hardware.ncd import ON_MAP, OFF_MAP, STATE_MAP
from pychron.hardware.ncd.ncd_device import NCDDevice


class ProXR(NCDDevice):
    '''
        implement the actuator interface
        open_channel
        close_channel
        get_channel_state
    '''
Example #25
0
def suite():
    # set env. variables
    os.environ['MassSpecDBVersion'] = '16'

    from pychron.paths import paths
    paths.build('_dev')

    if use_logger:
        from pychron.core.helpers.logger_setup import logging_setup
        logging_setup('unittests')

    from pychron.entry.tests.sample_loader import SampleLoaderTestCase
    from pychron.core.helpers.tests.floatfmt import FloatfmtTestCase
    from pychron.processing.tests.analysis_modifier import AnalysisModifierTestCase
    from pychron.experiment.tests.backup import BackupTestCase
    from pychron.core.xml.tests.xml_parser import XMLParserTestCase
    from pychron.entry.tests.analysis_loader import XLSAnalysisLoaderTestCase
    from pychron.entry.tests.irradiation_loader import XLSIrradiationLoaderParseTestCase, \
        XLSIrradiationLoaderLoadTestCase
    from pychron.entry.tests.massspec_irrad_export import MassSpecIrradExportTestCase
    from pychron.core.regression.tests.regression import OLSRegressionTest, MeanRegressionTest, \
        FilterOLSRegressionTest, OLSRegressionTest2
    from pychron.experiment.tests.frequency_test import FrequencyTestCase, FrequencyTemplateTestCase
    from pychron.experiment.tests.position_regex_test import XYTestCase
    from pychron.experiment.tests.renumber_aliquot_test import RenumberAliquotTestCase

    from pychron.external_pipette.tests.external_pipette import ExternalPipetteTestCase
    from pychron.processing.tests.plateau import PlateauTestCase
    from pychron.processing.tests.ratio import RatioTestCase
    from pychron.pyscripts.tests.extraction_script import WaitForTestCase
    from pychron.pyscripts.tests.measurement_pyscript import InterpolationTestCase, DocstrContextTestCase
    from pychron.experiment.tests.conditionals import ConditionalsTestCase, ParseConditionalsTestCase
    from pychron.experiment.tests.identifier import IdentifierTestCase
    from pychron.experiment.tests.comment_template import CommentTemplaterTestCase

    loader = unittest.TestLoader()
    suite = unittest.TestSuite()

    tests = (SampleLoaderTestCase,
             AnalysisModifierTestCase,
             BackupTestCase,
             MassSpecIrradExportTestCase,
             XMLParserTestCase,
             XLSIrradiationLoaderLoadTestCase,
             XLSIrradiationLoaderParseTestCase,
             XLSAnalysisLoaderTestCase,
             RatioTestCase,
             InterpolationTestCase,
             DocstrContextTestCase,
             OLSRegressionTest,
             OLSRegressionTest2,
             MeanRegressionTest,
             FilterOLSRegressionTest,
             PlateauTestCase,
             ExternalPipetteTestCase,
             WaitForTestCase,
             XYTestCase,
             FrequencyTestCase,
             FrequencyTemplateTestCase,
             RenumberAliquotTestCase,
             ConditionalsTestCase,
             ParseConditionalsTestCase,
             IdentifierTestCase,
             CommentTemplaterTestCase,
             FloatfmtTestCase)

    for t in tests:
        suite.addTest(loader.loadTestsFromTestCase(t))

    return suite
Example #26
0
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ===============================================================================

from pychron.paths import paths

paths.build('dev')

# ============= enthought library imports =======================
from traits.api import HasTraits, Str, Int, Bool, Any, Float, Property, on_trait_change, Instance, Button
from traitsui.api import View, UItem, Item, HGroup, VGroup
# ============= standard library imports ========================
# ============= local library imports  ==========================
from traitsui.handler import Handler
from pychron.dvc.dvc import DVC
from pychron.graph.stacked_regression_graph import StackedRegressionGraph
from pychron.loggable import Loggable


class KlassHandler(Handler):
    def object_good_button_changed(self, info):
        info.object.klass = 1
Example #27
0
    def _start_recording(self):
        self._recording = True
        self.record_data_manager = dm = self._record_data_manager_factory()
        dm.new_frame(directory=paths.furnace_scans_dir)
        dm.write_to_frame(('time', 'temperature', 'output'))
        self._start_time = time.time()

    def _stop_recording(self):
        self._recording = False

    def traits_view(self):
        v = View(VGroup(Item('setpoint'), Item('temperature_readback', style='readonly'),
                        HGroup(UItem('start_record_button'), UItem('stop_record_button'),
                               Item('recording_period', label='Period (m)')),
                        UItem('graph', style='custom')),

                 title='Standalone Furnace Controller')
        return v


if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup

    paths.build(os.path.join(os.path.expanduser('~'), 'PychronFurnace'))
    logging_setup('furnace_record', use_archiver=False)
    f = SimpleFurnace()
    f.bootstrap()
    f.controller.bootstrap()
    f.start_update()
    f.configure_traits()
Example #28
0
    def _start_recording(self):
        self._recording = True
        self.record_data_manager = dm = self._record_data_manager_factory()
        dm.new_frame(directory=paths.furnace_scans_dir)
        dm.write_to_frame(('time', 'temperature', 'output'))
        self._start_time = time.time()

    def _stop_recording(self):
        self._recording = False

    def traits_view(self):
        v = View(VGroup(
            Item('setpoint'), Item('temperature_readback', style='readonly'),
            HGroup(UItem('start_record_button'), UItem('stop_record_button'),
                   Item('recording_period', label='Period (m)')),
            UItem('graph', style='custom')),
                 title='Standalone Furnace Controller')
        return v


if __name__ == '__main__':
    from pychron.core.helpers.logger_setup import logging_setup

    paths.build(os.path.join(os.path.expanduser('~'), 'PychronFurnace'))
    logging_setup('furnace_record', use_archiver=False)
    f = SimpleFurnace()
    f.bootstrap()
    f.controller.bootstrap()
    f.start_update()
    f.configure_traits()
# ==============================================================================
#    getters
# ==============================================================================

    def get_powermaps(self, **kw):
        return self._retrieve_items(PowerMapTable)
#        return self._get_items(PowerMapTable, globals(), **kw)

# =============================================================================
#   adder
# =============================================================================
    def add_powermap(self, **kw):
        b = PowerMapTable(**kw)
        self._add_item(b)
#        b = self._add_timestamped_item(PowerMapTable, **kw)
        return b

if __name__ == '__main__':
    paths.build('_diode')
    db = PowerMapAdapter(name=paths.powermap_db,
                         kind='sqlite')
    db.connect()

    dbs = PowerMapSelector(db=db)
    dbs.load_recent()
    dbs.configure_traits()


# ============= EOF =============================================
Example #30
0
import time

from uncertainties import ufloat

from pychron.core.ui import set_toolkit

set_toolkit('qt4')

from pychron.paths import paths, build_directories

paths.build('_unittest')
build_directories(paths)

from pychron.core.helpers.logger_setup import logging_setup

logging_setup('peak_hop')

from threading import Thread
from pychron.experiment.utilities.mass_spec_database_importer import MassSpecDatabaseImporter
from pychron.processing.arar_age import ArArAge
from pychron.spectrometer.ion_optics.ion_optics_manager import IonOpticsManager
from pychron.spectrometer.thermo.manager.argus import ArgusSpectrometerManager
from pychron.experiment.automated_run.automated_run import AutomatedRun
from pychron.experiment.automated_run.spec import AutomatedRunSpec

import unittest

#HOPS = [('Ar40:H1:10,     Ar39:AX,     Ar36:CDD', 5, 1),
#        #('Ar40:L2,     Ar39:CDD',                   5, 1)
#        #('Ar38:CDD',                                5, 1)
#        ('Ar37:CDD', 5, 1)
Example #31
0
 def setUp(self):
     paths.build('_dt')
     self.dt = AutomatedRunDurationTracker()
Example #32
0
def suite():
    # set env. variables
    os.environ['MassSpecDBVersion'] = '16'

    from pychron.paths import paths
    paths.build('_dev')

    if use_logger:
        from pychron.core.helpers.logger_setup import logging_setup
        logging_setup('unittests')

    # Canvas
    from pychron.canvas.canvas2D.tests.calibration_item import CalibrationObjectTestCase

    # Core
    from pychron.core.tests.spell_correct import SpellCorrectTestCase
    from pychron.core.tests.filtering_tests import FilteringTestCase
    from pychron.core.stats.tests.peak_detection_test import MultiPeakDetectionTestCase
    from pychron.core.helpers.tests.floatfmt import FloatfmtTestCase
    from pychron.core.helpers.tests.strtools import CamelCaseTestCase
    from pychron.core.xml.tests.xml_parser import XMLParserTestCase
    from pychron.core.regression.tests.regression import OLSRegressionTest, MeanRegressionTest, \
        FilterOLSRegressionTest, OLSRegressionTest2, TruncateRegressionTest, ExpoRegressionTest, ExpoRegressionTest2
    from pychron.core.tests.alpha_tests import AlphaTestCase

    # DataMapper
    from pychron.data_mapper.tests.usgs_vsc_file_source import USGSVSCFileSourceUnittest, \
        USGSVSCIrradiationSourceUnittest
    from pychron.data_mapper.tests.nu_file_source import NuFileSourceUnittest
    from pychron.data_mapper.tests.nmgrl_legacy_source import NMGRLLegacySourceUnittest

    # Experiment
    from pychron.experiment.tests.repository_identifier import ExperimentIdentifierTestCase
    from pychron.experiment.tests.peak_hop_parse import PeakHopYamlCase1
    from pychron.experiment.tests.peak_hop_parse import PeakHopYamlCase2
    from pychron.experiment.tests.backup import BackupTestCase
    from pychron.experiment.tests.peak_hop_parse import PeakHopTxtCase
    from pychron.experiment.tests.duration_tracker import DurationTrackerTestCase
    from pychron.experiment.tests.frequency_test import FrequencyTestCase, FrequencyTemplateTestCase
    from pychron.experiment.tests.position_regex_test import XYTestCase
    from pychron.experiment.tests.renumber_aliquot_test import RenumberAliquotTestCase
    from pychron.experiment.tests.conditionals import ConditionalsTestCase, ParseConditionalsTestCase
    from pychron.experiment.tests.identifier import IdentifierTestCase
    from pychron.experiment.tests.comment_template import CommentTemplaterTestCase

    # ExternalPipette
    from pychron.external_pipette.tests.external_pipette import ExternalPipetteTestCase

    # Processing
    from pychron.processing.tests.plateau import PlateauTestCase
    from pychron.processing.tests.ratio import RatioTestCase
    from pychron.processing.tests.age_converter import AgeConverterTestCase

    # Pyscripts
    from pychron.pyscripts.tests.extraction_script import WaitForTestCase
    from pychron.pyscripts.tests.measurement_pyscript import InterpolationTestCase, DocstrContextTestCase

    # Spectrometer
    from pychron.spectrometer.tests.mftable import MFTableTestCase, DiscreteMFTableTestCase
    from pychron.spectrometer.tests.integration_time import IntegrationTimeTestCase

    from pychron.stage.tests.stage_map import StageMapTestCase, TransformTestCase

    loader = unittest.TestLoader()
    suite = unittest.TestSuite()

    tests = (
        # Canvas
        CalibrationObjectTestCase,

        # Core
        AlphaTestCase,
        SpellCorrectTestCase,
        FilteringTestCase,
        MultiPeakDetectionTestCase,
        FloatfmtTestCase,
        CamelCaseTestCase,
        RatioTestCase,
        XMLParserTestCase,
        OLSRegressionTest,
        MeanRegressionTest,
        ExpoRegressionTest,
        ExpoRegressionTest2,
        FilterOLSRegressionTest,
        OLSRegressionTest2,
        TruncateRegressionTest,

        # DataMapper
        USGSVSCFileSourceUnittest,
        USGSVSCIrradiationSourceUnittest,
        NuFileSourceUnittest,
        NMGRLLegacySourceUnittest,

        # Experiment
        ExperimentIdentifierTestCase,
        PeakHopYamlCase1,
        PeakHopYamlCase2,
        BackupTestCase,
        PeakHopTxtCase,
        DurationTrackerTestCase,
        FrequencyTestCase,
        FrequencyTemplateTestCase,
        XYTestCase,
        RenumberAliquotTestCase,
        ConditionalsTestCase,
        ParseConditionalsTestCase,
        IdentifierTestCase,
        CommentTemplaterTestCase,

        # ExternalPipette
        ExternalPipetteTestCase,

        # Processing
        PlateauTestCase,
        RatioTestCase,
        AgeConverterTestCase,

        # Pyscripts
        WaitForTestCase,
        InterpolationTestCase,
        DocstrContextTestCase,

        # Spectrometer
        MFTableTestCase,
        DiscreteMFTableTestCase,
        IntegrationTimeTestCase,

        # Stage
        StageMapTestCase,
        TransformTestCase)

    for t in tests:
        suite.addTest(loader.loadTestsFromTestCase(t))

    return suite
Example #33
0
 def setUp(self):
     paths.build('_dt')
     self.dt = AutomatedRunDurationTracker()
Example #34
0
def initialize_version(appname, debug):
    root = os.path.dirname(__file__)

    if not debug:
        add_eggs(root)
    else:
        build_sys_path()

    # from pychron.environment.util import get_environment
    # env = get_environment(appname)
    from pychron.envisage.user_login import get_user
    args = get_user()
    if args is None:
        return False
    else:
        user, env = args

    # if not env:
    #     logger.info('no environment available')
    #     from pyface.directory_dialog import DirectoryDialog
    #
    #     information(None, 'An "environment" directory is not set in Preferences/General. Please select a valid '
    #                       'directory')
    #     dlg = DirectoryDialog(action='open', default_directory=os.path.expanduser('~'))
    #     result = dlg.open()
    #     if result == OK:
    #         env = str(dlg.path)
    #         from pychron.environment.util import set_environment
    #         set_environment(appname, env)
    # else:

    if not env:
        return False

    set_application_home(appname, env)

    from pychron.paths import paths
    logger.debug('using Pychron environment: {}'.format(env))
    paths.build(env)

    from configparser import ConfigParser, NoSectionError
    cp = ConfigParser()
    pref_path = os.path.join(ETSConfig.application_home, 'preferences.ini')
    cp.read(pref_path)
    try:
        cp.set('pychron.general', 'environment', env)
    except NoSectionError:
        cp.add_section('pychron.general')
        cp.set('pychron.general', 'environment', env)

    root = os.path.dirname(pref_path)
    if not os.path.isdir(root):
        os.mkdir(root)

    with open(pref_path, 'w') as wfile:
        cp.write(wfile)

    # build globals
    build_globals(user, debug)

    from pychron.core.helpers.logger_setup import logging_setup
    from pychron.paths import build_directories

    # build directories
    build_directories()
    paths.write_defaults()

    # setup logging. set a basename for log files and logging level
    logging_setup('pychron', level='DEBUG')

    from pychron.core.helpers.exception_helper import set_exception_handler
    set_exception_handler()

    return env
    def closed(self, info, ok):
        if ok:
            info.object.save()


class SpectrometerParametersView(HasTraits):
    model = Instance("SpectrometerParameters")

    def trait_context(self):
        return {"object": self.model}

    def traits_view(self):
        v = View(
            UItem("groups", style="custom", editor=ListEditor(mutable=False, use_notebook=True, page_name=".name")),
            buttons=["OK", "Cancel"],
            handler=SHandler,
            title="Spectrometer Settings",
            kind="livemodal",
        )

        return v


if __name__ == "__main__":
    paths.build("_dev")
    s = SpectrometerParameters()
    s.load()
    v = SpectrometerParametersView(model=s)
    v.configure_traits()
# ============= EOF =============================================
Example #36
0
def suite():
    # set env. variables
    os.environ['MassSpecDBVersion'] = '16'

    from pychron.paths import paths
    paths.build('_dev')

    if use_logger:
        from pychron.core.helpers.logger_setup import logging_setup
        logging_setup('unittests')

    from pychron.canvas.canvas2D.tests.calibration_item import CalibrationObjectTestCase
    from pychron.experiment.tests.duration_tracker import DurationTrackerTestCase
    from pychron.core.tests.spell_correct import SpellCorrectTestCase
    from pychron.core.tests.filtering_tests import FilteringTestCase
    from pychron.core.stats.tests.peak_detection_test import MultiPeakDetectionTestCase
    from pychron.experiment.tests.repository_identifier import ExperimentIdentifierTestCase

    from pychron.stage.tests.stage_map import StageMapTestCase, \
        TransformTestCase
    from pychron.entry.tests.sample_loader import SampleLoaderTestCase
    from pychron.core.helpers.tests.floatfmt import FloatfmtTestCase
    from pychron.processing.tests.analysis_modifier import AnalysisModifierTestCase
    from pychron.experiment.tests.backup import BackupTestCase
    from pychron.core.xml.tests.xml_parser import XMLParserTestCase
    from pychron.entry.tests.analysis_loader import XLSAnalysisLoaderTestCase
    from pychron.core.regression.tests.regression import OLSRegressionTest, MeanRegressionTest, \
        FilterOLSRegressionTest, OLSRegressionTest2
    from pychron.experiment.tests.frequency_test import FrequencyTestCase, FrequencyTemplateTestCase
    from pychron.experiment.tests.position_regex_test import XYTestCase
    from pychron.experiment.tests.renumber_aliquot_test import RenumberAliquotTestCase

    from pychron.external_pipette.tests.external_pipette import ExternalPipetteTestCase
    from pychron.processing.tests.plateau import PlateauTestCase
    from pychron.processing.tests.ratio import RatioTestCase
    from pychron.pyscripts.tests.extraction_script import WaitForTestCase
    from pychron.pyscripts.tests.measurement_pyscript import InterpolationTestCase, DocstrContextTestCase
    from pychron.experiment.tests.conditionals import ConditionalsTestCase, ParseConditionalsTestCase
    from pychron.experiment.tests.identifier import IdentifierTestCase
    from pychron.experiment.tests.comment_template import CommentTemplaterTestCase

    loader = unittest.TestLoader()
    suite = unittest.TestSuite()

    tests = (CalibrationObjectTestCase,
             DurationTrackerTestCase,
             SpellCorrectTestCase,
             # SimilarTestCase,
             FilteringTestCase,
             MultiPeakDetectionTestCase,
             ExperimentIdentifierTestCase,
             StageMapTestCase,
             TransformTestCase,
             SampleLoaderTestCase,
             AnalysisModifierTestCase,
             BackupTestCase,
             # MassSpecIrradExportTestCase,
             XMLParserTestCase,

             XLSAnalysisLoaderTestCase,

             RatioTestCase,
             InterpolationTestCase,
             DocstrContextTestCase,
             OLSRegressionTest,
             OLSRegressionTest2,
             MeanRegressionTest,
             FilterOLSRegressionTest,
             PlateauTestCase,
             ExternalPipetteTestCase,
             WaitForTestCase,
             XYTestCase,
             FrequencyTestCase,
             FrequencyTemplateTestCase,
             RenumberAliquotTestCase,
             ConditionalsTestCase,
             ParseConditionalsTestCase,
             IdentifierTestCase,
             CommentTemplaterTestCase,
             FloatfmtTestCase)

    for t in tests:
        suite.addTest(loader.loadTestsFromTestCase(t))

    return suite
Example #37
0
# ===============================================================================
from pychron.hardware.core.data_helper import make_bitarray
'''
    National Control Devices
    
   http://www.controlanything.com/ 
   
   The Complete ProXR Command Set:
   http://www.controlanything.com/Relay/Device/A0010
   http://assets.controlanything.com/manuals/ProXR.pdf
'''

from pychron.paths import paths
from pychron.core.helpers.logger_setup import logging_setup
logging_setup('prox')
paths.build('_prox')

# ============= enthought library imports =======================
# ============= standard library imports ========================
# ============= local library imports  ==========================
from pychron.hardware.ncd import ON_MAP, OFF_MAP, STATE_MAP
from pychron.hardware.ncd.ncd_device import NCDDevice


class ProXR(NCDDevice):
    '''
        implement the actuator interface
        open_channel
        close_channel
        get_channel_state
    '''
Example #38
0
        proot = cp.get("pychron.general", "root_dir")
    except BaseException, e:
        print "root_dir exception={}".format(e)
        from pyface.directory_dialog import DirectoryDialog

        information(None, "Pychron root directory not set in Preferences/General. Please select a valid directory")
        dlg = DirectoryDialog(action="open", default_directory=os.path.expanduser("~"))
        result = dlg.open()
        if result == OK:
            proot = str(dlg.path)

    if not proot:
        return False

    logger.debug("using Pychron root: {}".format(proot))
    paths.build(proot)
    try:
        cp.set("pychron.general", "root_dir", proot)
    except NoSectionError:
        cp.add_section("pychron.general")
        cp.set("pychron.general", "root_dir", proot)

    root = os.path.dirname(pref_path)
    if not os.path.isdir(root):
        os.mkdir(root)

    with open(pref_path, "w") as wfile:
        cp.write(wfile)

    # build globals
    build_globals(debug)
Example #39
0
def main1():
    from random import random

    # from pychron.paths import paths

    paths.build('_dev')

    # def add_runs(c, e):
    # class Spec():
    #         def __init__(self, record_id):
    #             self.runid = record_id
    #             # self.mass_spectrometer = 'jan'
    #             # self.extract_device = 'LF'
    #             self.analysis_timestamp = datetime.now()
    #             self.state = choice(['Finished', 'Canceled', 'Failed'])
    #             self.analysis_type = "unknown"
    #             self.sample = "FC-2"
    #             self.extract_value = random() * 2
    #             self.extract_units = 'watts'
    #             self.duration = randint(100, 200)
    #             self.cleanup = randint(100, 200)
    #             self.position = randint(0, 100)
    #             self.comment = "Test comment"
    #             self.material = "sanidine"
    #             self.project = "Monitor"
    #             self.measurement_script = 'unknown400_180'
    #             self.extraction_script = 'sniffair_x1'
    #             self.post_measurement_script = 'pump_spectrometer'
    #             self.post_equilibration_script = 'pump_extraction_line'
    #
    #     class Run():
    #         def __init__(self, *args, **kw):
    #             self.spec = Spec(*args, **kw)
    #
    #     for i in range(6):
    #         c.add_run(Run('20016-{:02d}'.format(i + 1)), e)
    #
    # def add_experiment(c):
    #     class Exp():
    #         def __init__(self, name, user, status):
    #             self.name = name
    #             self.username = user
    #             spec = choice(('Jan','Obama'))
    #             self.spectrometer = spec
    #             self.mass_spectrometer = spec
    #             self.extract_device = choice(('Fusions CO2', 'Fusions Diode'))
    #             self.status = status
    #             self.starttime = datetime.now()
    #
    #     e = Exp('Current Experiment', 'foobar', 'Running')
    #     c.add_experiment(e)
    #     return e
    #
    # def update_status(c):
    #     c.update_status(Error='Error big time')
    #     c.update_status(Message='This is a long message',
    #                     ShortMessage='This is a short message')

    def add_measurements(c):
        for i in range(100):
            c.add_measurement('AirPressure', 'pneumatics', random(), 'PSI')
            c.add_measurement('Environmental', 'temperature',
                              random() * 2 + 70, 'C')
            c.add_measurement('Environmental', 'humidity',
                              random() * 5 + 50, '%')

            time.sleep(1)

    logging_setup('labspyclient', use_archiver=False)
    # c = LabspyClient(bind=False, host='129.138.12.138', port=27017)
    # c = MeteorLabspyClient(bind=False, host='localhost', port=3001)
    # # update_state(c)
    # for i in range(10):
    # add_device(c)
    # time.sleep(1)

    clt = LabspyClient(bind=False)
    clt.db.host = 'localhost'
    clt.db.username = os.environ.get('DB_USER')
    clt.db.password = os.environ.get('DB_PWD')
    clt.db.name = 'labspy'
    clt.test_connection()

    # set status
    # update_status(clt)

    # measurements
    add_measurements(clt)
Example #40
0
        proot = cp.get('pychron.general', 'root_dir')
    except BaseException, e:
        print 'root_dir exception={}'.format(e)
        from pyface.directory_dialog import DirectoryDialog

        information(None, 'Pychron root directory not set in Preferences/General. Please select a valid directory')
        dlg = DirectoryDialog(action='open', default_directory=os.path.expanduser('~'))
        result = dlg.open()
        if result == OK:
            proot = str(dlg.path)

    if not proot:
        return False

    logger.debug('using Pychron root: {}'.format(proot))
    paths.build(proot)
    try:
        cp.set('pychron.general', 'root_dir', proot)
    except NoSectionError:
        cp.add_section('pychron.general')
        cp.set('pychron.general', 'root_dir', proot)

    root = os.path.dirname(pref_path)
    if not os.path.isdir(root):
        os.mkdir(root)

    with open(pref_path, 'w') as wfile:
        cp.write(wfile)

    # build globals
    build_globals(debug)
Example #41
0
from pychron.core.ui import set_toolkit

set_toolkit('qt4')

from pychron.paths import paths

paths.build('_unittest')
#build_directories(paths)

from pychron.core.helpers.logger_setup import logging_setup

logging_setup('packager')

from test.database import isotope_manager_factory
from pychron.processing.vcs_data.packager import Packager



import unittest


class ArArAgeCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.isotope_man = isotope_manager_factory(name='pychrondata_minnabluff')
        cls.isotope_man.db.connect()
        man = cls.isotope_man
        db = man.db
        with db.session_ctx():
            ans, tc = db.get_sample_analyses(['AF-72', ], ['Minna Bluff'])
            cls.analyses=man.make_analyses(ans)
Example #42
0
                 kind='livemodal', buttons=['OK', 'Cancel'])
        return v

    def _measurement_script_default(self):
        s = Script(label='measurement')
        return s

    def _extraction_script_default(self):
        s = Script(label='extraction')
        return s


if __name__ == '__main__':
    from pychron.paths import paths

    paths.build('~/PychronDev')
    af = BulkRunFixer()


    class Run:
        extraction_script = 'Foo'
        measurement_script = 'Bar'
        analysis_type = 'unknown'


    a = Run()
    a.analysis_type = 'air'
    b = Run()
    b.analysis_type = 'blank'
    c = Run()
    runs = [a, b, c]
Example #43
0
from pychron.core.helpers.iterfuncs import partition
from pychron.core.ui import set_qt


set_qt()
# ============= enthought library imports =======================

# ============= standard library imports ========================
# ============= local library imports  ==========================
from pychron.paths import paths
from pychron.geo.shape_file_writer import ShapeFileWriter
from pychron.core.helpers.logger_setup import logging_setup
from pychron.geo.processor import GeoProcessor

paths.build('_dev')
logging_setup('geo')

SamplePoint = namedtuple('SamplePoint', 'x,y,sample,material,labnumber')

src = pyproj.Proj(init='EPSG:4326')
dest = pyproj.Proj(init='EPSG:3031')  #,proj='utm', zone='58')
# ellps='WGS84')

def proj_pt(lat, long):
    x, y = pyproj.transform(src, dest, long, lat)
    return x, y


def get_processor(database='pychrondata_dev'):
    geo = GeoProcessor(bind=False, connect=False)
Example #44
0
                               fontsize=12,
                               fontsize_name='fontsize',
                               wrap=False,
                               tab_width=15)

        v = View(VGroup(VGroup(grp, label='Editor'),
                        VGroup(UItem('object.text',
                                     editor=teditor,
                                     style='custom'), label='Text')),
                 # toolbar=ToolBar(),
                 width=690,
                 title=self.title,
                 buttons=['OK', save_action, save_as_acion],
                 resizable=True)
        return v


if __name__ == '__main__':
    root = os.path.join(os.path.expanduser('~'), 'PychronDev')
    paths.build(root)
    m = HopEditorModel()
    m.detectors = ['H2', 'H1', 'CDD']
    # m.open()
    m.new()
    h = HopEditorView(model=m)
    # m.new()
    h.configure_traits()


# ============= EOF =============================================