Пример #1
0
    def get_logs(self, 
                 q_log: witsml.obj_log,
                 returnElements: str='id-only') -> witsml.logs:
        '''Get logs from a witsml store server
    
        The default is to return id-only, change to all when you know what log to get.
        Pass an empty log with returnElements id-only to get all by id.
    
    
        Args:
            q_log (witsml.obj_log): A query log specifing objects to return, for example uidWell, uidWellbore or an empty log
            returnElements (str): String describing data to get on of [all, id-only, header-only, data-only, station-location-only
                                                                       latest-change-only, requested]
        Returns:
            witsml.logs: logs a collection of log
        
        Raises:
            pyxb.exception: If the reply is empty or the document fails to validate a pyxb exception is raised
        '''
    
        q_logs = witsml.logs(version=witsml.__version__)
    
        q_logs.append(q_log)
    
        reply_logs = self.soap_client.service.WMLS_GetFromStore('log',
                                                                q_logs.toxml(),
                                                                OptionsIn=f'returnElements={returnElements}'
                                                               )

        return witsml.CreateFromDocument(reply_logs.XMLout)
Пример #2
0
 def get_bhaRuns(self, 
                 q_bha: witsml.obj_bhaRun,
                 returnElements: str='id-only') -> witsml.bhaRuns:
     '''Get bhaRuns from a witsml store server
 
     The default is only to return id-only, change to all when you know what bhaRun to get.
 
 
     Args:
         q_bha (witsml.obj_bhaRun): A query bhaRun specifing objects to return, can be an empty bhaRun
         returnElements (str): String describing data to get on of [all, id-only, header-only, data-only, station-location-only
                                                                    latest-change-only, requested]
     Returns:
         witsml.bhaRuns: bhaRuns a collection of bhaRun
     
     Raises:
         pyxb.exception: If the reply is empty or the document fails to validate a pyxb exception is raised
     '''
 
     q_bhas = witsml.bhaRuns(version=witsml.__version__)
 
     q_bhas.append(q_bha)
 
     reply_bhas = self.soap_client.service.WMLS_GetFromStore('bhaRun',
                                                             q_bhas.toxml(),
                                                             OptionsIn=f'returnElements={returnElements}'
                                                            )
 
     return witsml.CreateFromDocument(reply_bhas.XMLout)
Пример #3
0
 def get_trajectorys(self, 
                     q_traj: witsml.obj_trajectory,
                     returnElements: str='id-only') -> witsml.trajectorys:
     '''Get trajectorys from a witsml store server
 
     The default is only to return id-only, change to all when you know what trajectory to get.
     Pass an empty trajectory with returnElements id-only to get all by id.
 
     Args:
         q_traj (witsml.obj_trajectory): A query trajectory specifing objects to return
         returnElements (str): String describing data to get on of [all, id-only, header-only, data-only, station-location-only
                                                                    latest-change-only, requested]
     Returns:
         witsml.trajectorys: trajectorys, a collection of trajectory
     
     Raises:
         pyxb.exception: If the reply is empty or the document fails to validate a pyxb exception is raised
     '''
 
     q_trajs = witsml.trajectorys(version=witsml.__version__)
 
     q_trajs.append(q_traj)
 
     reply_traj = self.soap_client.service.WMLS_GetFromStore('trajectory',
                                                             q_trajs.toxml(),
                                                             OptionsIn=f'returnElements={returnElements}'
                                                            )
 
     return witsml.CreateFromDocument(reply_traj.XMLout)
Пример #4
0
def test_obj_dict_mudLog():

    with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    print(type(obj))
    flatt_witsml = ku.obj_dict(obj.mudLog[0], True)
    assert flatt_witsml['commonData.comments'] == 'MudLog Object'
    assert len(flatt_witsml) == 1244
Пример #5
0
def test_plural_dict_geoIntervall():

    with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    geo_frame = ku.plural_dict(obj.mudLog[0].geologyInterval, True)

    assert geo_frame['mdTop'][0:6] == [
        1860.0, 1870.0, 1880.0, 1890.0, 1890.0, 1900.0
    ]
    assert len(geo_frame) == 28
Пример #6
0
def test_obj_dict_risk():

    with open(os.path.join(sample_path, 'risk.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    flatt_witsml = ku.obj_dict(obj.risk[0], True)

    assert flatt_witsml['mitigation[0]'] == 'Call the boss'
    assert flatt_witsml['mitigation[1]'] == 'Run for cover'
    assert flatt_witsml['uidWellbore'] == 'OC-bf-wb1'
    assert flatt_witsml['nameWellbore'] == 'Wellbore Test Bruce'
    assert len(flatt_witsml) == 45
Пример #7
0
def test_log_to_dict(test_filename):

    with open(os.path.join(sample_path, test_filename), 'r') as test_file:
        logs = witsml.CreateFromDocument(test_file.read())

    logdata_frame = ku.logdata_dict(logs.log[0])

    for mnem in logs.log[0].logData[0].mnemonicList.split(','):
        assert mnem in logdata_frame

    assert len(list(logdata_frame.values())[0]) == len(
        logs.log[0].logData[0].data)

    if logs.log[0].indexType == 'measured depth':
        assert isinstance(logdata_frame[logs.log[0].indexCurve][0], float)
    else:
        assert isinstance(logdata_frame[logs.log[0].indexCurve][0], datetime)
Пример #8
0
def test_plural_dict_lithology():

    with open(os.path.join(sample_path, 'mudLog.xml'), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())

    lit_frame = ku.plural_dict(obj.mudLog[0].geologyInterval[1].lithology,
                               True)
    lit_frame_no_attr = ku.plural_dict(
        obj.mudLog[0].geologyInterval[1].lithology, False)

    for lit in [lit_frame, lit_frame_no_attr]:
        assert lit['lithPc'] == [70.0, 30.0]
        assert lit['codeLith'] == ['300', '405']
        assert lit['description'] == [
            'Clay Clay-shale [Symbol not found, used by default]',
            'Sand Fine sandstone'
        ]

    assert lit_frame['uid'] == [
        "6e106c6c-07f1-4288-b1d3-f3238606c1a8-Lith0",
        "6e106c6c-07f1-4288-b1d3-f3238606c1a8-Lith1"
    ]
    assert len(lit_frame) == 6
    assert len(lit_frame_no_attr) == 4
Пример #9
0
def test_unmarshalling(test_filename):
    '''Test unmarshalling energistics well A test files'''
    with open(os.path.join(sample_path, test_filename), 'r') as test_file:
        obj = witsml.CreateFromDocument(test_file.read())