Esempio n. 1
0
 def __init__(self, segy, *args, **kwargs):
     self.TRACE_TABLE = kwargs.pop('trace_table', TRACE_TABLE)
     self.TRACE_FIELDS = kwargs.pop('trace_fields', TRACE_FIELDS)
     if 'database' not in kwargs:
         database = ':memory:'
     else:
         database = kwargs['database']
     RockfishDatabaseConnection.__init__(self, database)
     # add header values to the database
     self.init_header_database(segy)
Esempio n. 2
0
    def __init__(self, filename=None, database=':memory:', *args, **kwargs):
        """
        Class for working with UKOOA P1/90 data.

        :param filename: Optional. Filename of a P1/90 file to read data from.
            Default is to create an empty P190 class instance.
        :param database: Optional. Filename of a SQLite database to store P1/90
            data in. Default is to create a temporary database in memory.
        :param *args: Optional.  Arguments to pass to
            :class:`sqlite3.Connection`
        :param *kwargs: Optional.  Keyword arguments to pass to
            :class:`sqlite3.Connection`
        """
        RockfishDatabaseConnection.__init__(self, database, *args, **kwargs)
        self.HEADER_TABLE = HEADER_TABLE
        self.COORDINATE_TABLE = COORDINATE_TABLE
        self.RECEIVER_TABLE = RECEIVER_TABLE
        self._create_tables()

        if filename: 
            self.filename = filename
            self.read()
Esempio n. 3
0
 def __init__(self, database, *args, **kwargs):
     # pull key words from kwargs that apply to this init only
     if 'extra_pick_fields' in kwargs:
         extra_pick_fields = kwargs.pop('extra_pick_fields')
     else:
         extra_pick_fields = None
     if 'extra_trace_fields' in kwargs:
         extra_trace_fields = kwargs.pop('extra_trace_fields')
     else:
         extra_trace_fields = None
     if 'extra_event_fields' in kwargs:
         extra_event_fields = kwargs.pop('extra_event_fields')
     else:
         extra_event_fields = None
     # tell user that this is a new database
     if not os.path.isfile(database):
         print "Creating new database: {:}".format(database)
     # create the base instance
     RockfishDatabaseConnection.__init__(self, database, *args, **kwargs)
     # build tables
     self.PICK_TABLE = PICK_TABLE
     self.PICK_FIELDS = PICK_FIELDS
     self.create_pick_table(extra_fields=extra_pick_fields)
     self.EVENT_TABLE = EVENT_TABLE
     self.EVENT_FIELDS = EVENT_FIELDS
     self.create_event_table(extra_fields=extra_event_fields)
     self.TRACE_TABLE = TRACE_TABLE
     self.TRACE_FIELDS = TRACE_FIELDS
     self.create_trace_table(extra_fields=extra_trace_fields)
     # create views
     self.MASTER_VIEW = MASTER_VIEW
     self.VMTOMO_PICK_VIEW = VMTOMO_PICK_VIEW
     self.VMTOMO_PICK_FIELDS = VMTOMO_PICK_FIELDS
     self.VMTOMO_SHOT_VIEW = VMTOMO_SHOT_VIEW
     self.VMTOMO_SHOT_FIELDS = VMTOMO_SHOT_FIELDS
     self.VMTOMO_INSTRUMENT_VIEW = VMTOMO_INSTRUMENT_VIEW
     self.VMTOMO_INSTRUMENT_FIELDS = VMTOMO_INSTRUMENT_FIELDS
     self.create_views()
Esempio n. 4
0
 def test__add_field_if_not_exists(self):
     """
     Should add a field only if it does not already exist.
     """
     db = RockfishDatabaseConnection(':memory:')
     field_name = 'field1'
     fields = [(field_name, 'REAL', None, False, False)]
     db._create_table_if_not_exists('table1', fields)
     # should have the field
     current_fields = db._get_fields('table1')
     self.assertEqual(len(current_fields), 1)
     # try to add the field again
     db._add_field_if_not_exists('table1', field_name)