Esempio n. 1
0
	def _set_lat_lng(self):
		try:
			self.lat, self.lng = conformBCOGCLatLon(self.row[8], self.row[9])
		except:
			print "INFO:  not able to find lat, long in BCOGC licence, using UWI", self.row
			if self.uwi[-4]=="W":   
				uwiIn="00/" + self.uwi[3:5] + "-" + self.uwi[5:7] + "-" + self.uwi[7:10] + "-" + self.uwi[10:14] + "/0"                     
				self.lat, self.lng = uwiToLatLng.convert(uwiIn)                                                                         
			else:                                                                                                           
				self.lat, self.lng = uwiToLatLng.convert(self.uwi, grid="NTS")  
			random.seed(int(re.sub("[^0-9]","", self.licnum)))       
			self.lat += random.uniform(-0.0005,0.0005)                                                                        
			self.lng += random.uniform(-0.0005,0.0005)   
Esempio n. 2
0
	def _set_lat_lng(self):
		if len(re.findall('Surface Location:.*', self.entry)) == 1:
			surfuwi = re.sub('Surface Location:\s+', '', re.findall('Surface Location:.*', self.entry)[0])
		elif len(re.findall('Surf. Location:.*', self.entry)) == 1:
			surfuwi = re.sub('Surf. Location:\s+', '', re.findall('Surf. Location:.*', self.entry)[0])
		elif len(re.findall('UWI:.*', self.entry)) == 1:
			surfuwi = re.sub('UWI:\s+', '', re.findall('UWI:.*', self.entry)[0])
			surfuwi = re.sub('[0-9][0-9][0-9]\.', '', surfuwi)
			surfuwi = re.sub('W[0-9]\.[0-9][0-9]', '', surfuwi)
		else:
			raise Exception('No valid surface uwi found ', self.entry)

		offsets = re.sub('Co-ords: ', '', re.findall('Co-ords.*\n.*', self.entry)[0])
		offsets = re.sub(' W ', ' (W) ', re.sub(' E ', ' (E) ', re.sub(' N', ' (N) ', re.sub(' S ',' (S) ', offsets))))

		gridPosition = self._get_grid_position(offsets)
		surfuwi = self._conform_uwi(surfuwi)

		if gridPosition == 'ne': 
			surfuwi = '-'.join(['16'] + surfuwi.split('-')[1:])
		elif gridPosition == 'nw':
			surfuwi = '-'.join(['09'] + surfuwi.split('-')[1:])
		elif gridPosition == 'sw':
			surfuwi = '-'.join(['04'] + surfuwi.split('-')[1:])
		elif gridPosition == 'se':
			surfuwi = '-'.join(['01'] + surfuwi.split('-')[1:])

		lat, lng = uwiToLatLng.convert(surfuwi, position = gridPosition)
		latOffset, lngOffset = self._calc_offset(offsets, lat)
		self.lat = lat + latOffset
		self.lng = lng + lngOffset
Esempio n. 3
0
def add_ab_drilling_to_database(drillingFileAll, verbose = False):
  """ Query for all AB well spuds, parse them into a common format and add to database (csv) """
  province = "AB"

  for year in range(2011, datetime.datetime.now().year + 1):
      files = []
      for (dirpath, dirnames, filenames) in os.walk(IONWC_HOME + '/data/spud/' + str(year) + '/'):
          files.extend(filenames)
          break
      
      for file in files:
          wells = _aer_parse_spud_file(IONWC_HOME + '/data/spud/' + str(year) + '/' + file)
          if verbose: print 'INFO:  Reading file ' + IONWC_HOME + '/data/spud/' + str(year) + '/' + file
          for i in range(len(wells)):
              try:
                  uwi = wells[i][0]
                  lat, lon = uwiToLatLng.convert(uwi)
                  licencee = wells[i][9].replace(',','')
                  well_name = wells[i][1].replace(',','')
                  licence_number   = wells[i][2]
                  uwi      = wells[i][0]
                  driller  = wells[i][4].replace(',','')
                  rig      = wells[i][5]
                  month = file[-8:-6]
                  day   = file[-6:-4]

                  random.seed(int(re.sub("[^0-9]","",licence_number)))
                  lat += random.uniform(-0.0005,0.0005)
                  lon += random.uniform(-0.0005,0.0005)

                  writeDrillingFile(drillingFileAll, licencee, well_name, licence_number, uwi, str(year), month, day, driller, rig, lat, lon, province)
              except:
                  print "WARN: skipping AER spud of well", wells[i]
Esempio n. 4
0
def add_bc_drilling_to_database(drillingFileAll, verbose = False):
    """ Query for all BC well spuds, parse them into a common format and add to database (csv) """
    files = []
    province = "BC"

    for (dirpath, dirnames, filenames) in os.walk(IONWC_HOME + '/data/spud/bc/'):
        files.extend(filenames)
        break

    for file in files:
        file_contents = ''.join(open(IONWC_HOME + '/data/spud/bc/' + file).readlines())
        spuds = re.findall('[0-9]+.+[\s]+[0-9]+[A-Z]+[0-9]+[\s]+[\w]+[\s]+[a-zA-z]+[\s]+[0-9]+', file_contents)
        for spud in spuds:
            licence_number = re.findall('[0-9]+\s+', spud)[0]
            well_name = re.split('[0-9]+[A-Z]+[0-9]+', spud)[0].replace(licence_number, '')

            #Create Licensee name using the well name
            licencee = UNKNOWN
            for key in BC_WELL_NAME_TO_OPERATOR_MAP:
                if key in well_name.lower():
                    licencee = BC_WELL_NAME_TO_OPERATOR_MAP[key]

            try:
                uwi = re.findall('[0-9]+[A-Z][0-9]+[A-Z][0-9]+[A-Z][0-9]+', spud)[0]
                lat, lon = uwiToLatLng.convert(uwi, grid = "NTS")
            except:
                uwi = re.findall('[0-9]+W[0-9]+', spud)[0]
                uwi = "00/" + uwi[3:5] + "-" + uwi[5:7] + "-" + uwi[7:10] + "-" + uwi[10:14] + "/0"     
                lat, lon = uwiToLatLng.convert(uwi)

            drill_date = re.findall('[0-9]{4}[A-Z]{3}[0-9]+', spud)[0]
            year = drill_date[0:4]
            month = MONTH_DICT[drill_date[4:7]]
            day = drill_date[7:9]

            driller = re.findall('[a-zA-Z]+', spud)[-1]
            rig = re.findall('[0-9]+', spud)[-1]

            random.seed( int(re.sub('[^0-9]', '', licence_number)) )
            lat += random.uniform(-0.0005, 0.0005)
            lon += random.uniform(-0.0005, 0.0005)

            writeDrillingFile(drillingFileAll, licencee, well_name, licence_number, uwi, year, month, day, driller, rig, lat, lon, province)
Esempio n. 5
0
	def _set_lat_lng(self):
		metersPerKm = 1000.0

		surfuwi = self.row[3] + '-' + self.row[4] + '-' + self.row[5].zfill(3) + '-' + self.row[6] + 'W' + self.row[7]
		offsets = [self.row[44], self.row[42], self.row[48], self.row[46]]
		lat, lng = uwiToLatLng.convert("00/"+ surfuwi +"/0")

		yOffset = self._xy_sign(offsets[0]) * float(offsets[1]) / metersPerKm
		xOffset = self._xy_sign(offsets[2]) * float(offsets[3]) / metersPerKm

		kmPerDegreeLat, kmPerDegreeLng = km_per_degree_lat_lng(lat)

		self.lat = lat + self._safe_divide(yOffset, kmPerDegreeLat)
		self.lng = lng + self._safe_divide(xOffset, kmPerDegreeLng)
Esempio n. 6
0
	def _set_lat_lng(self):
		metersPerKm = 1000.0

		surfuwi = self.well_bore_entry[18]
		offsets = [self.well_bore_entry[15], self.well_bore_entry[14], self.well_bore_entry[17], self.well_bore_entry[16]]

		lat, lng = uwiToLatLng.convert("00/"+ surfuwi +"/0")

		yOffset = self._xy_sign(offsets[0]) * float(offsets[1]) / metersPerKm
		xOffset = self._xy_sign(offsets[2]) * float(offsets[3]) / metersPerKm

		kmPerDegreeLat, kmPerDegreeLng = km_per_degree_lat_lng(lat)

		self.lat = lat + self._safe_divide(yOffset, kmPerDegreeLat)
		self.lng = lng + self._safe_divide(xOffset, kmPerDegreeLng)
Esempio n. 7
0
	def _set_lat_lng(self):
		metersPerKm = 1000.0

		surfUWI = re.split('\s\s+', self.entry[4])[-1]
		offsets = re.split('\s+', self.entry[1])[1:5]

		yOffset = self._xy_sign(offsets[0]) * float(offsets[1][:-1]) / metersPerKm
		xOffset = self._xy_sign(offsets[2]) * float(offsets[3][:-1]) / metersPerKm

		lat, lng = uwiToLatLng.convert(surfUWI)

		kmPerDegreeLat, kmPerDegreeLng = km_per_degree_lat_lng(lat)

		self.lat = lat + self._safe_divide(yOffset, kmPerDegreeLat)
		self.lng = lng + self._safe_divide(xOffset, kmPerDegreeLng)
Esempio n. 8
0
def addBCFacilitiesToDataBase(facilitiesFileAll):
    """ Query for all BC facilities, parse them into a common format and add to database (csv) """
    bcfacilties = 0

    allBCLics = open(IONWC_HOME + "/data/facilities/bc/facilities.csv")
    reader = csv.reader(allBCLics)

    # Skip header (first row)
    next(reader)

    for row in reader:
        facilityId = row[1]
        facilityType = row[2]
        objectType = row[3]
        activity = row[4]
        organization = row[5]
        location = row[
            6]  # B-023-E/094-A-14 --> 200B077D094H0300  or 06-06-086-13
        approvalDate = row[7]
        constructionStartDate = row[8]
        pressureTestDate = row[9]
        leaveToOpenDate = row[10]
        asBuiltDate = row[11]
        tenureFileNumber = row[12]
        legalSurveyApprovalDate = row[13]
        facilityStatus = row[14]

        uwi = conform_uwi(location)

        lat, lon = uwiToLatLng.convert(uwi)
        random.seed(int(re.sub("[^0-9]", "", facilityId)))
        lat += random.uniform(-0.0005, 0.0005)
        lon += random.uniform(-0.0005, 0.0005)

        writeFaciltiesFile(facilitiesFileAll, facilityId, facilityType,
                           organization, lat, lng)
        bcfacilties += 1

    print "INFO:  Found", bcfacilties, " facilities for BC"
Esempio n. 9
0
def add_sk_drilling_to_database(drillingFileAll, verbose = False):
    """ Query for all SK well spuds, parse them into a common format and add to database (csv) """
    files = []
    province = "SK"
    for (dirpath, dirnames, filenames) in os.walk(IONWC_HOME + '/data/spud/sask/'):
        files.extend(filenames)
        break

    well_name = UNKNOWN
    rig = UNKNOWN

    for file in files:
        if verbose: print 'INFO:  Reading file ' + IONWC_HOME + '/data/spud/sask/' + file

        descript, surfuwi = _sk_parse_spud_file(IONWC_HOME + '/data/spud/sask/' + file)

        for i in range(len(surfuwi)):
            try:
                uwi = surfuwi[i]
                lat, lon = uwiToLatLng.convert("00/"+ uwi +"/0")
                licencee = descript[i][14][1:-1].replace(',','')
                licence_number = descript[i][12][1:-1]
                uwi = descript[i][1][1:-1]
                driller = descript[i][16][1:-1].replace(',','')
                year = file[-14:-10]
                month = file[-9:-7]
                day  = file[-6:-4]

                random.seed(int(re.sub("[^0-9]","",licence_number)))
                lat += random.uniform(-0.0005,0.0005)
                lon += random.uniform(-0.0005,0.0005)

                writeDrillingFile(drillingFileAll, licencee, well_name, licence_number, uwi, year, month, day, driller, rig, lat, lon, province)

            except: 
                print 'WARN: Skipping SK spud of well uwi ', uwi, ' description: ', descript[i]
Esempio n. 10
0
def add_mb_drilling_to_database(drillingFileAll, verbose = False):
    """ Query for all MB well spuds, parse them into a common format and add to database (csv) """
    files = []
    province = "MB"

    for (dirpath, dirnames, filenames) in os.walk(IONWC_HOME + '/data/activity/mb/'):
        files.extend(filenames)
        break

    mb_wells = 0

    for file in files:
        fi = open(IONWC_HOME + '/data/activity/mb/' + file)
        if verbose: print 'INFO:  Reading file ' + IONWC_HOME + '/data/activity/mb/' + file
        t = fi.read()
        t1 = t.split('Lic. No.:')
        wells = t1[1:]
        rig = UNKNOWN

        for well in wells:
            if 'spud date:' in well.lower():
                well = well.split('\n')
                licence_number, well_name, licencee, uwi, driller = "", "", UNKNOWN, "", UNKNOWN
                licence_number = well[0].strip().split(' ')[0]

                well_name = well[0].strip().replace(licence_number,'').strip()
                try:
                    indexLicensee = [i for i, s in enumerate(well) if 'Licensee' in s][0]
                    licencee = well[indexLicensee].strip().split(':')[1].strip()
                except: 
                    #Create Licensee name using the well name
                    for key in MB_WELL_NAME_TO_OPERATOR_MAP:
                        if key in well_name.lower():
                            licencee = MB_WELL_NAME_TO_OPERATOR_MAP[key]
                    if licencee == UNKNOWN:
                      print "WARN: No Operator found for MB drilling well ", well

                try:
                    indexUWI = [i for i, s in enumerate(well) if 'UWI' in s][0]
                    uwi = well[indexUWI].strip().split(':')[1][0:22].strip()
                except:
                    print "WARN:  Assuming UWI is at second index"
                    uwi = well[1].strip()[0:22]
                    pass
                uwi = uwi.replace('.','/')
                lat, lon = uwiToLatLng.convert(uwi)

                random.seed(int(re.sub("[^0-9]","",licence_number)))
                lat += random.uniform(-0.0005,0.0005)
                lon += random.uniform(-0.0005,0.0005)

                print well
                indexDate = [i for i, s in enumerate(well) if 'spud date:' in s.lower()][0]
                date = well[indexDate].strip().split(':')[1].strip().split('-')
                year = date[2]
                if int(year)>=2010:
                    month = date[1]
                    month = MONTH_DICT[month.upper()]
                    day = date[0]

                    try:
                        indexField = [i for i, s in enumerate(well) if 'Field' in s][0]
                        field = well[indexField].strip().split(':')[1].strip()
                    except: pass

                    try:
                        indexDriller = [i for i, s in enumerate(well) if 'Contractor' in s][0]
                        driller = well[indexDriller].strip().split(':')[1].strip()
                    except: pass

                    try: float(licence_number)
                    except: print "ERROR: Non numerical licence number found"

                    mb_wells += 1
                    writeDrillingFile(drillingFileAll, licencee, well_name, 'MB' + licence_number, uwi, year, month, day, driller, rig, lat, lon, province)

    print "INFO: Number of well spuds in Manitoba: ", mb_wells