V1 Api Overview

Create Seismic API client

Before we can do anything, we need to create a client that can interact with the Cognite Seismic API.

[3]:
from cognite.seismic import CogniteSeismicClient
[4]:
import os
import getpass

api_key = os.environ.get("COGNITE_API_KEY")
if api_key is None:
    api_key = getpass.getpass("Enter your Cognite API key: ")

client = CogniteSeismicClient(
    api_key=api_key,
    base_url="https://api.cognitedata.com:443",
    project="seismic-test"  # Specify the correct project name
    )

Surveys

Register a survey

Much like in existing seismic databases, surveys serve as the basic unit of organization for seismic data. Before registering a Segy file, we first need to register a survey to act as a container for the Segy file.

[10]:
survey_name = "my_new_survey"
[12]:
# Register our survey. If it already exists, an exception will be thrown.
from grpc import RpcError
try:
    my_survey = client.survey.register(survey_name)
    print(my_survey)
except RpcError as e:
    print(e._state.details)
survey with name: my_new_survey already exists.
[13]:
# We can also attach metadata to a survey when registering it.
try:
    my_survey_2 = client.survey.register(survey_name + "_meta", {"area": "B13", "processed": "False"})
    print(my_survey_2)
except RpcError as e:
    print(e._state.details)
survey with name: my_new_survey_meta already exists.

Retrieve a survey

There are multiple methods for finding an existing survey such as by id, by name, by listing the surveys, or by searching for surveys that intersect with a given coverage.

Retrieve a survey by name

[15]:
my_survey = client.survey.get(survey_name=survey_name)
print(my_survey)
survey {
  id: "6ef538bb-ad42-4eef-af7e-99d2497e85ae"
  name: "my_new_survey"
}

List all available surveys

[16]:
# list all surveys
surveys = client.survey.list()
print(surveys)
surveys {
  id: "5b7bba87-41f1-42ac-b205-a3e64d83004c"
  name: "TUN15M02"
}
surveys {
  id: "d879de35-2999-4628-af72-b413ea4e5ee1"
  name: "F3"
}
surveys {
  id: "24f2a3df-1464-4a6c-b563-7a7061d24da2"
  name: "third"
}
surveys {
  id: "32335957-7d69-4214-a1b3-d12110241bec"
  name: "Test Geospatial"
}
surveys {
  id: "bab2b37d-90df-4198-8d62-d191e1425bd8"
  name: "Test Geospatial1"
}
surveys {
  id: "cfb9fc2a-bb0c-4e11-adea-53576307336c"
  name: "test"
}
surveys {
  id: "dda57888-6718-49c4-b65c-130fa0339d7a"
  name: "test-survey-upload"
}
surveys {
  id: "c833290c-eafd-4f08-9a8f-4ec114b0c4fd"
  name: "Hellos"
}
surveys {
  id: "83c0d4b1-37ec-4212-97ef-335e8138e9f3"
  name: "my_survey_1"
}
surveys {
  id: "67b37045-32ae-417a-a39d-66b991c53f54"
  name: "my_survey_2"
}
surveys {
  id: "6d487b6c-b90d-4c2f-aa69-40213b94d0b6"
  name: "my_survey"
}
surveys {
  id: "6ef538bb-ad42-4eef-af7e-99d2497e85ae"
  name: "my_new_survey"
}
surveys {
  id: "f9573bd0-61a5-4837-9308-61185b32b824"
  name: "my_new_survey_meta"
}

Files

Files are the primary method to ingest seismic data.

Register a file

With a survey assigned, we can register a file to the survey. The file must already be uploaded to gcloud storage before this step.

[17]:
file_name = "straight-small.sgy"
bucket = "gs://cognite-seismic-eu/tests/"
crs = "EPSG:23031"
[19]:
# Now we can register the segy file that we will ingest.
# The file must be uploaded to gcloud storage before ingestion.
try:
    file = client.file.register(survey_id=my_survey.survey.id, bucket=bucket, file_name=file_name, crs=crs)
    print(file)
except RpcError as e:
    print(e._state.details)
file with name: straight-small.sgy already exists.

Retrieve a file

Similar to surveys, we can find an existing file by its unique id, or its name.

[20]:
file = client.file.get(file_name=file_name)
print(file)
file {
  id: "b4e46555-4af6-4570-aa3a-cc91022c3a87"
  name: "straight-small.sgy"
}
crs: "EPSG:23031"
path: "gs://cognite-seismic-eu/tests/"
survey_name: "my_survey_1"
last_step: "Compute coverage"

We can also list all files that are visible in the project.

[21]:
for file_entry in client.file.list():
    print(file_entry)
    print("--------\n")
id: "4f40e205-1e16-431b-a0fe-63c5e1377675"
name: "ST14003ABPR17_KPSDM_FINAL_STACK_03-30_TIME.sgy"
metadata {
  key: "author"
  value: "tuan"
}

--------

id: "67ddf40d-248a-458c-8668-382b8e528923"
name: "writeback_test"
is_temporary: true

--------

id: "0cd3b924-7ccf-46f8-8f98-2c100209e92e"
name: "f3.sgy"
metadata {
  key: "source"
  value: "smoke_test"
}

--------

id: "4e1e6e62-54bf-4a5d-b187-3def4120b5c9"
name: "TUN15M02-FINAL-STACK.MIG_FIN.POST_STACK..JS-022102.segy"
metadata {
  key: "opendata"
  value: "N"
}

--------

id: "b4e46555-4af6-4570-aa3a-cc91022c3a87"
name: "straight-small.sgy"

--------

id: "4ce7d29b-b59b-41cc-9089-b7f4c403d7ec"
name: "normal-small.sgy"

--------

id: "9668ee9d-a867-4de4-a022-ad65990e8364"
name: "123.sgy"

--------

id: "8f05b284-5055-4f44-933f-461f2e76c57d"
name: "BPN0501R08_00_FU_T_PSDM_RT+25.sgy"
metadata {
  key: "text"
  value: "geospatial test"
}

--------

id: "8ffe76b8-52fd-4684-80a5-1a47c1429dbd"
name: "final-stack-03-30.sgy"
metadata {
  key: "author"
  value: "tuan"
}

--------

id: "d117eabc-ac1e-40e4-8dc0-85a0ae9366c3"
name: "f3-lsb.sgy"

--------

We can also list all the files that are registered to a specific survey:

[22]:
# get a specific survey and list files belonging to it
survey = client.survey.get(survey_name=survey_name, list_files=True)
print(survey)
#iterate over files in the survey
for file in survey.files:
    print(file.name)
survey {
  id: "6ef538bb-ad42-4eef-af7e-99d2497e85ae"
  name: "my_new_survey"
}

Ingest a file

With the file registered to our survey, we can now trigger an ingestion job which will get queued in the background.

[23]:
ingestion_job = client.file.ingest(file_id=file.file.id)
print(ingestion_job)
job_id: "d9a73cd6-4168-4b1d-b340-9364ca6fabf7"
file_id: "b4e46555-4af6-4570-aa3a-cc91022c3a87"

Check ingest job status

We can check the status of the ingest job we triggered in the code snippets below.

[24]:
# Get current status
print(client.job.status(ingestion_job.job_id))
status: SUCCESS
message: "Job processed successfully"
started_at: "2020-10-14 13:43:08.281682"
updated_at: "2020-10-14 13:43:13.870687"

[25]:
# Periodically check status until complete
from cognite.seismic.protos.types_pb2 import JobStatus
import time

check = client.job.status(ingestion_job.job_id)

while (check.status != JobStatus.SUCCESS):
    time.sleep(5)
    check = client.job.status(ingestion_job.job_id)
    print(check)

SeismicStores

Once a file has been ingested, a “seismic store” is created from that data. The seismic store represents the actual trace data that lives in the service.

Listing

[5]:
stores = client.seismicstore.list()
print(stores[50])
SeismicStore<id: 791535037228196, name: normal-small-scaled236.sgy, survey_id: ef64f24e-d56a-4ad2-8c85-9e3b3c097c09, ingestion_source: 1, metadata: {}, storage_tier: []>

Get metadata/header information about a seismic store

[10]:
# List() does not include all data, so we fetch the specific id we are interested in
store = client.seismicstore.get(11, coverage_crs="", coverage_format="wkt")  # Can specify 'geojson' instead
crs = store.coverage.crs
[35]:
# Binary header
print(store.binary_header)
#   Raw binary header
print(store.binary_header.raw_header)
# Text header
print(store.text_header)
BinaryHeader<traces: 1, trace_data_type: 5, fixed_length_traces: 0, segy_revision: 0, auxtraces: 0, interval: 4000, interval_original: 0, samples: 1065, samples_original: 0, ensemble_fold: 1, vertical_sum: 1, trace_type_sorting_code: 4, sweep_type_code: 0, sweep_frequency_start: 0, sweep_frequency_end: 0, sweep_length: 0, sweep_channel: 0, sweep_taper_start: 0, sweep_taper_end: 0, sweep_taper_type: 0, correlated_traces: 0, amplitude_recovery: 0, original_measurement_system: 1, impulse_signal_polarity: 1, vibratory_polarity_code: 0>
b''
TextHeader<C 1 SEGY OUTPUT FROM Petrel 2016.3 (64-bit) Tuesday, November 28 2017 17:37:48
C 2 Name: ST14003ABPR17_KPSDM_FINAL_STACK_03-30_TIME Type: 3D seismic
C 3
C 4 First inline: 1504   Last inline: 4327
C 5 First xline:  2527   Last xline:  7868
C 6 CRS: ED50 * EPSG-Nor N62 2001 / UTM zone 36N  23036*1612  (ED50 / UTM zone 3
C 7 X min: 534333.23 max: 592604.35 delta: 58271.13
C 8 Y min: 8041251.68 max: 8116468.08 delta: 75216.41
C 9 Time min: -4258.00 max: 2.00 delta: 4260.00
C10 Lat min: 72.26'53.0103"N max: 73.08'18.9277"N delta: 0.41'25.9174"
C11 Long min: 34.01'15.3157"E max: 35.51'30.0308"E delta: 1.50'14.7152"
C12 Trace min: -4256.00 max: 0.00 delta: 4256.00
C13 Seismic (template) min: -8712.99 max: 7827.22 delta: 16540.21
C14 Amplitude (data) min: -8712.99 max: 7827.22 delta: 16540.21
C15 Trace sample format: IBM floating point
C16 Coordinate scale factor: 1.00000
C17
C18 Binary header locations:
C19 Sample interval             : bytes 17-18
C20 Number of samples per trace : bytes 21-22
C21 Trace date format           : bytes 25-26
C22
C23 Trace header locations:
C24 Inline number               : bytes 5-8
C25 Xline number                : bytes 21-24
C26 Coordinate scale factor     : bytes 71-72
C27 X coordinate                : bytes 73-76
C28 Y coordinate                : bytes 77-80
C29 Trace start time/depth      : bytes 109-110
C30 Number of samples per trace : bytes 115-116
C31 Sample interval             : bytes 117-118
C32
C33
C34
C35
C36
C37
C38
C39
C40 END EBCDIC                                                                  >
[36]:
# coverage in wkt
store.coverage
[36]:
Geometry<crs: EPSG:23031, wkt: POLYGON Z((542483.0003455688 8061666.000001558 -24.236952419392765, 542555.0003455407 8061839.000001528 -24.23591397702694, 542608.0003455201 8061966.000001506 -24.235149754211307, 542680.0003454919 8062139.000001477 -24.234111754223704, 542733.0003454713 8062266.000001452 -24.233347854577005, 542805.0003454433 8062439.000001419 -24.23231029510498, 542858.0003454225 8062566.000001401 -24.231546719558537, 542930.0003453946 8062739.000001368 -24.230509603396058, 542983.000345374 8062866.000001347 -24.229746352881193, 543031.0003453551 8062981.000001331 -24.229055227711797, 543108.0003453252 8063166.000001296 -24.22794675268233, 543156.0003453066 8063281.000001277 -24.22725591994822, 543233.0003452766 8063466.000001241 -24.226147918961942, 543358.000345228 8063766.000001191 -24.224349847994745, 543483.0003451793 8064066.000001139 -24.222552546299994, 543608.0003451307 8064366.000001086 -24.220756009221077, 543637.0003451194 8064435.000001074 -24.220339350402355, 543709.0003450915 8064608.00000104 -24.219304987229407, 543762.0003450708 8064735.00000102 -24.218543755821884, 543834.0003450428 8064908.000000989 -24.217509833164513, 543887.0003450222 8065035.000000969 -24.21674892771989, 543935.0003450036 8065150.000000946 -24.21605992782861, 543940.0003450016 8065162.000000944 -24.215988162904978, 544012.0003449736 8065335.000000914 -24.214954869821668, 544065.000344953 8065462.000000892 -24.214194426313043, 544137.0003449251 8065635.000000862 -24.21316157374531, 544190.0003449046 8065762.000000841 -24.21240145806223, 544262.0003448765 8065935.000000808 -24.2113690469414, 544315.0003448561 8066062.00000079 -24.21060925349593, 544387.000344828 8066235.000000757 -24.209577286615968, 544440.0003448075 8066362.000000736 -24.20881781540811, 544488.0003447888 8066477.000000717 -24.2081301137805, 544493.0003447869 8066489.000000714 -24.208058485761285, 544565.000344759 8066662.0000006845 -24.20702714473009, 544613.0003447403 8066777.000000661 -24.20633973646909, 544618.0003447384 8066789.00000066 -24.2062681382522, 544690.0003447104 8066962.0000006305 -24.205237242393196, 544743.0003446898 8067089.000000609 -24.204478558152914, 544815.000344662 8067262.000000577 -24.20344810374081, 544868.0003446414 8067389.000000558 -24.202689746394753, 544940.0003446136 8067562.000000526 -24.20165973342955, 544993.000344593 8067689.000000504 -24.20090170018375, 545065.000344565 8067862.000000471 -24.19987212959677, 545118.0003445445 8067989.000000452 -24.19911441858858, 545166.0003445259 8068104.000000429 -24.19842830952257, 545243.000344496 8068289.000000398 -24.197327905334532, 545291.0003444775 8068404.000000378 -24.196642089635134, 545368.0003444477 8068589.0000003455 -24.195542158558965, 545493.0003443992 8068889.000000294 -24.193757178261876, 545522.0003443881 8068958.000000278 -24.193343179300427, 545594.0003443602 8069131.00000025 -24.1923154797405, 545647.0003443398 8069258.000000228 -24.19155914336443, 545719.0003443118 8069431.000000196 -24.190531883388758, 550516.0003424656 8080973.999998177 -24.122666276060045, 551747.000341995 8083927.999997658 -24.105432896874845, 555892.0003404202 8093873.999995916 -24.04795217793435, 558806.0003393216 8100865.999994685 -24.008047728799284, 558984.0003392546 8101292.999994608 -24.00562369544059, 559032.0003392366 8101407.999994588 -24.0049702571705, 559061.0003392257 8101476.999994575 -24.004575422033668, 559296.0003391359 8101487.99999457 -24.00125473551452, 560978.0003384936 8101558.9999945415 -23.97749769780785, 563280.0003376156 8101655.999994499 -23.94501859880984, 565582.0003367384 8101752.999994449 -23.91257998906076, 567884.000335862 8101849.999994393 -23.880181877873838, 579835.0003313087 8102353.9999939315 -23.712635996751487, 583818.0003297803 8102521.999993689 -23.657039462588727, 587802.0003282377 8102689.999993386 -23.601550431922078, 591138.00032693 8102829.999993078 -23.555180043913424, 592378.0003264388 8102881.999992949 -23.537965768016875, 592585.0003263566 8102889.999992926 -23.535093083046377, 592596.0003263522 8102884.999992928 -23.53493917454034, 592587.0003263558 8102861.999992928 -23.53505880292505, 592337.0003264543 8102261.999993056 -23.538392432034016, 591659.0003267208 8100634.999993405 -23.547448774799705, 587514.0003283329 8090688.999995473 -23.603307395242155, 586057.0003288947 8087192.999996177 -23.62314289342612, 584850.0003293589 8084296.999996753 -23.639653967693448, 584744.0003293995 8084042.999996807 -23.641107440926135, 584696.0003294181 8083927.999996829 -23.641765797510743, 579847.0003312764 8072324.999999084 -23.708855868317187, 579799.0003312947 8072209.999999107 -23.70952573325485, 579775.0003313039 8072151.999999119 -23.709860702976584, 579727.0003313222 8072036.999999143 -23.710530737414956, 579722.0003313241 8072024.999999145 -23.710600540041924, 579674.0003313426 8071909.999999164 -23.711270701140165, 579650.0003313518 8071851.999999176 -23.71160581894219, 579597.000331372 8071724.9999992 -23.712345980107784, 579549.0003313904 8071609.999999221 -23.713016434572637, 579525.0003313997 8071551.999999233 -23.71335170045495, 579424.0003314383 8071309.99999928 -23.714762933552265, 579400.0003314475 8071251.9999992885 -23.715098350308836, 579299.0003314861 8071009.999999334 -23.716510206460953, 579275.0003314953 8070951.999999347 -23.716845769435167, 579174.000331534 8070709.999999393 -23.71825824305415, 579121.0003315543 8070582.999999415 -23.718999644741416, 579073.0003315727 8070467.999999438 -23.71967121772468, 579068.0003315746 8070455.999999442 -23.71974117960781, 579020.0003315929 8070340.999999465 -23.720412879250944, 579015.000331595 8070328.999999464 -23.72048285510391, 578996.0003316022 8070282.999999474 -23.720748772844672, 578948.0003316205 8070167.999999498 -23.72142064012587, 578943.0003316224 8070155.999999496 -23.72149063460529, 578895.0003316408 8070040.999999519 -23.722162628546357, 578890.0003316428 8070028.999999522 -23.722232633270323, 578871.0003316501 8069982.999999528 -23.722498670220375, 578818.0003316703 8069855.999999555 -23.723240856081247, 578770.0003316887 8069740.999999577 -23.723913142457604, 578765.0003316908 8069728.999999578 -23.723983178846538, 578746.0003316979 8069682.999999587 -23.72424933500588, 578693.0003317182 8069555.999999611 -23.72499184589833, 578645.0003317365 8069440.999999634 -23.725664427503943, 578640.0003317385 8069428.999999636 -23.7257344936952, 578621.0003317457 8069382.999999646 -23.726000766269863, 578568.0003317661 8069255.99999967 -23.726743603125215, 578520.0003317845 8069140.999999689 -23.727416477166116, 578515.0003317862 8069128.999999695 -23.727486575953662, 578496.0003317937 8069082.999999701 -23.727752964012325, 578443.0003318138 8068955.999999727 -23.7284961277619, 578395.0003318322 8068840.999999749 -23.72916929703206, 578390.0003318342 8068828.999999752 -23.729239424690604, 578342.0003318526 8068713.999999773 -23.729912721551955, 578337.0003318544 8068701.999999773 -23.729982861317694, 578318.0003318618 8068655.999999782 -23.730249419808388, 578270.0003318801 8068540.999999806 -23.730922882445157, 578265.000331882 8068528.999999806 -23.730993040837348, 578217.0003319005 8068413.999999825 -23.731666632927954, 578212.0003319024 8068401.999999829 -23.731736805289984, 578193.0003319096 8068355.999999839 -23.732003474608064, 578140.0003319299 8068228.999999864 -23.73274742346257, 578092.0003319484 8068113.999999884 -23.733421310782433, 578068.0003319575 8068055.999999895 -23.733758301474154, 578015.0003319777 8067928.999999921 -23.734502577222884, 577967.0003319961 8067813.999999943 -23.73517675511539, 577943.0003320053 8067755.999999953 -23.735513894818723, 577890.0003320256 8067628.999999979 -23.73625849559903, 577842.0003320441 8067513.999999999 -23.73693296685815, 577818.0003320532 8067456.00000001 -23.737270256504416, 577765.0003320735 8067329.000000034 -23.738015180453658, 577717.0003320919 8067214.000000054 -23.73868994601071, 577664.0003321122 8067087.00000008 -23.739435131661594, 577640.0003321215 8067029.000000091 -23.73977263364941, 577539.0003321602 8066787.000000137 -23.741193206049502, 577515.0003321694 8066729.000000145 -23.74153085332364, 577414.0003322081 8066487.000000193 -23.74295204412192, 577390.0003322172 8066429.000000205 -23.743289839476347, 577289.0003322558 8066187.00000025 -23.74471164960414, 577265.000332265 8066129.000000262 -23.74504959397018, 577164.0003323038 8065887.000000305 -23.74647202435881, 577111.0003323241 8065760.000000329 -23.747218646109104, 577063.0003323425 8065645.000000352 -23.747894953005016, 577058.0003323444 8065633.000000352 -23.747965407557786, 577039.0003323517 8065587.000000363 -23.748233165591955, 576986.000332372 8065460.000000383 -23.74898011237383, 576938.0003323904 8065345.000000407 -23.749656710773706, 576933.0003323923 8065333.000000411 -23.749727196991444, 576885.0003324107 8065218.000000431 -23.75040392111987, 576880.0003324127 8065206.000000433 -23.750474420376122, 576861.0003324199 8065160.000000444 -23.750742345117033, 576813.0003324384 8065045.000000463 -23.751419238746166, 576808.0003324401 8065033.000000468 -23.75148975569755, 571964.0003343009 8053442.000002618 -23.820378770120442, 571911.0003343213 8053315.000002638 -23.821138869039714, 571863.0003343398 8053200.00000266 -23.82182737533003, 571858.0003343417 8053188.000002661 -23.821899102069438, 571839.000334349 8053142.000002672 -23.82217173371464, 571786.0003343695 8053015.000002693 -23.822932154871523, 571738.0003343881 8052900.000002712 -23.823620955459774, 571733.00033439 8052888.000002718 -23.823692715726793, 571685.0003344084 8052773.000002738 -23.824381639249623, 571661.0003344176 8052715.000002749 -23.824726209044456, 571613.0003344361 8052600.000002772 -23.825415301136672, 571608.000334438 8052588.0000027735 -23.825487093999982, 571560.0003344566 8052473.000002795 -23.826176309026778, 571536.0003344658 8052415.000002804 -23.826521028764546, 571483.0003344862 8052288.0000028275 -23.827282235957682, 571435.0003345048 8052173.000002849 -23.827971750870347, 571411.000334514 8052115.000002859 -23.828316615894437, 571358.0003345344 8051988.0000028815 -23.82907814439386, 571310.000334553 8051873.000002902 -23.829767952673137, 571286.000334562 8051815.000002914 -23.83011296670884, 571233.0003345828 8051688.000002937 -23.830874822102487, 571185.0003346012 8051573.000002962 -23.83156492281705, 571161.0003346103 8051515.000002971 -23.831910081207752, 571108.0003346308 8051388.000002992 -23.832672266289592, 571060.0003346493 8051273.000003014 -23.833362656645477, 571007.0003346698 8051146.000003037 -23.834125102497637, 570983.0003346789 8051088.000003048 -23.834470474161208, 570935.0003346975 8050973.000003068 -23.835161162540317, 570882.000334718 8050846.000003092 -23.835923929698765, 570858.0003347272 8050788.000003102 -23.836269448511302, 570757.0003347662 8050546.000003146 -23.837723523378372, 570733.0003347755 8050488.000003156 -23.8380691902712, 570632.0003348145 8050246.0000032 -23.839523882605135, 570608.0003348237 8050188.000003213 -23.839869699440897, 570507.0003348627 8049946.000003256 -23.8413250092417, 570454.0003348832 8049819.000003279 -23.842088885605335, 570406.0003349016 8049704.0000033 -23.84278081730008, 570401.0003349037 8049692.000003302 -23.84285290259868, 570382.0003349109 8049646.00000331 -23.843126899562776, 570329.0003349314 8049519.000003336 -23.843891102820635, 570281.00033495 8049404.000003353 -23.844583327881992, 570276.0003349519 8049392.000003356 -23.844655442982912, 570228.0003349704 8049277.00000338 -23.84534779191017, 570223.0003349723 8049265.000003382 -23.845419922843575, 570204.0003349797 8049219.000003388 -23.84569408558309, 570156.0003349982 8049104.00000341 -23.84638660401106, 570151.0003350001 8049092.000003412 -23.846458749845624, 570103.0003350187 8048977.000003431 -23.847151391208172, 570098.0003350206 8048965.000003433 -23.847223550081253, 570079.000335028 8048919.000003445 -23.847497834824026, 570026.0003350484 8048792.000003466 -23.848262822255492, 569978.000335067 8048677.000003487 -23.84895575698465, 569973.0003350689 8048665.00000349 -23.849027948454022, 569954.0003350764 8048619.000003498 -23.849302348680794, 569901.0003350967 8048492.00000352 -23.850067663006485, 569853.0003351152 8048377.000003541 -23.850760891102254, 569848.0003351172 8048365.0000035465 -23.850833112373948, 569829.0003351246 8048319.000003552 -23.85110762901604, 569776.0003351452 8048192.0000035735 -23.851873266510665, 569728.0003351637 8048077.000003598 -23.852566790767014, 569723.0003351655 8048065.0000036 -23.852639042772353, 569704.000335173 8048019.000003607 -23.852913673967123, 569651.0003351934 8047892.00000363 -23.85367963835597, 569603.000335212 8047777.000003652 -23.854373455047607, 569598.0003352138 8047765.0000036545 -23.854445735923946, 569550.0003352324 8047650.000003673 -23.855139676481485, 569526.0003352418 8047592.000003684 -23.85548677574843, 569478.0003352603 8047477.000003704 -23.856180888600647, 569473.0003352622 8047465.0000037085 -23.856253198347986, 569425.0003352808 8047350.000003727 -23.85694743413478, 569401.00033529 8047292.000003741 -23.85729467589408, 569348.0003353105 8047165.000003765 -23.85806142538786, 569300.0003353291 8047050.000003781 -23.858755953609943, 569276.0003353384 8046992.000003794 -23.8591033462435, 569223.0003353588 8046865.000003818 -23.859870418906212, 569175.0003353774 8046750.000003838 -23.860565242357552, 569151.0003353867 8046692.000003848 -23.860912782140076, 569098.0003354072 8046565.000003872 -23.861680179834366, 569050.0003354258 8046450.000003892 -23.862375295720994, 569026.000335435 8046392.000003905 -23.862722982652485, 568944.0003354668 8046196.000003938 -23.863910750485957, 568910.00033548 8046116.0000039525 -23.86440310999751, 568894.0003354861 8046109.000003955 -23.864629428833723, 568810.000335518 8046103.000003959 -23.86581221036613, 568659.0003355753 8046098.000003966 -23.867937518283725, 565868.0003366364 8046029.000004035 -23.90724771656096, 558288.000339526 8045843.000004187 -24.01430851407349, 558042.0003396199 8045837.000004189 -24.017790374346077, 556168.0003403366 8045792.00000422 -24.04432979505509, 556045.0003403837 8045790.000004223 -24.04607247374952, 556033.0003403884 8045794.000004219 -24.046241748146713, 556010.000340397 8045804.00000422 -24.04656577948481, 555973.0003404111 8045846.000004216 -24.0470824316144, 555827.0003404665 8046015.000004182 -24.04912076611072, 555480.0003405982 8046417.00000412 -24.053966705687344, 543501.0003451766 8060469.000001766 -24.222513679414988, 542928.0003453973 8061142.000001647 -24.23063860926777, 542483.0003455688 8061666.000001558 -24.236952419392765))>

Download Segy file

Download a seismic store as a SEGY file.

[41]:
file_generator = client.file_seismic.get_segy(id=11)
# write sgy file to disk
with open("test.sgy", "wb") as output:
    for f in file_generator:
        output.write(f.content)

Download Segy file by inline / crossline range

Downloads the seismic store as a SEGY file with only the data inside the range of inlines and crosslines.

[9]:
# Getting line ranges
inline_range = store.inline_volume_def.common_inline_range()
xline_range = store.inline_volume_def.common_xline_range()

print(inline_range, xline_range)

file_generator = client.file_seismic.get_segy_by_lines(
    file_name=file_name,
    top_left_inline=inline_range.start,
    top_left_xline=xline_range.start,
    bottom_right_inline=inline_range.stop,
    bottom_right_xline=xline_range.stop
)

# write sgy file to disk
with open("test-partial.sgy", "wb") as output:
    for f in file_generator:
        output.write(f.content)
RangeInclusive(1504, 4327, 1) RangeInclusive(2527, 7868, 1)

Download Segy file by Polygon coverage

Downloads an existing SEGY file with only the data inside the given 2D polygon.

[12]:
wkt_polygon_coverage = "POLYGON((14.2857141494751 14.2857141494751,14.2857141494751 13.7142858505249,13.7142858505249 13.7142858505249,13.7142858505249 14.2857141494751,14.2857141494751 14.2857141494751))"
file_generator = client.file_seismic.get_segy_by_geometry(
    id=11,
    crs=crs,
    wkt=wkt_polygon_coverage
)
# write sgy file to disk
with open("test-geometry.sgy", "wb") as output:
    for f in file_generator:
        output.write(f.content)

Find minimum and maximum inline and crossline values for a seismic store

[13]:
inline_range = store.inline_volume_def.common_inline_range()
xline_range = store.inline_volume_def.common_xline_range()

print(inline_range, xline_range)
RangeInclusive(1504, 4327, 1) RangeInclusive(2527, 7868, 1)

Get all crosslines for an inline in a seismic store

[15]:
xlines = store.inline_volume_def.get_inline_range()
print(xlines[3643])
(2527, 7868)

Get all inlines for a crossline in a seismic store

[18]:
inlines = store.xline_volume_def.get_xline_range()
print(inlines[2527])
(1504, 4327)

Slices

Seismic slice by volume

Returns the traces of an volume in a given seismic store, specified by inline range, xline range, and (optional, slow) z-range.

[22]:
inline_range = (2527, 2627)
xline_range = (1504, 1800)

# Can get an estimate of the volume size
size = client.volume_seismic.get_volume_size(seismic_store_id=11, inline_range=inline_range, xline_range=xline_range)
print(f"Estimated size: {size.trace_count}")

volume = [x for x in client.volume_seismic.get_volume(seismic_store_id=11, inline_range=inline_range, xline_range=xline_range)]
print(volume)
Estimated size: 0

Seismic slice by arbitrary line

TODO: Given a line from points x0, y0 to x1, y1, this function returns the series of traces that are along that line.

Get a trace from specific coordinate position

TODO

Partitions

While seismic stores are sufficient for most single-tenant situations, you may find it useful to create views into subsections of seismic data, or even allow limited access to external users that are not internal to your organization. “Seismics” are no-copy subsets of seismic store data that are grouped into partitions.

Partitions are a unit of access. You can assign partitions to service accounts using the Cognite API’s /api/v1/projects/[PROJECT_NAME]/groups endpoint (documented here). Below is a Python example.

[24]:
import requests
import json

url = "https://api.cognitedata.com/api/v1/projects/[PROJECT_NAME]/groups"

# The name of the new group
group_name = json.dumps("my-new-capability-group")

# The seismics to assign to the partition
seismic_ids = json.dumps([14,21])

payload="""
{
    "items": [
        {
            "name": %s,
            "capabilities": [
                {
                    "projectsAcl": {
                        "actions": ["READ"],
                        "scope": { "all": {} }
                    }
                },
                {
                    "seismicAcl": {
                        "actions": ["READ"],
                        "scope": {
                            "partition": {
                                "partition_ids": %s
                            }
                        }
                    }
                },
                {
                    "geospatialAcl": {
                        "actions": [
                            "READ"
                        ],
                        "scope": {
                            "all": {}
                        }
                    }
                }
            ]
        }
    ]
}
""" % (group_name, seismic_ids,)

headers = {
  'api-key': api_key,
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Creating a partition

[6]:
partition = client.partition.create(external_id="my-partition-external-id", name="optional name")
print(partition)
Partition<id: 4166332971015156, external_id: my-partition-external-id, name: optional name>

Search partitions

[21]:
# by ID
client.partition.search(id=partition.id)
# by external ID
client.partition.search(external_id=partition.external_id)
# by external ID substring
client.partition.search(external_id_substring="external-id")
# by name
client.partition.search(name="optional name")
# by name substring
client.partition.search(name_substring="name")
# list partitions
client.partition.list()
# simply get a partition
client.partition.get(external_id=partition.external_id)
[21]:
Partition<id: 4166332971015156, external_id: my-partition-external-id, name: optional name>

Delete partitions

[ ]:
client.partition.delete(external_id=partition.external_id)

Seismics

Creating seismics

Seismics are a view into seismic store data. So when creating a seismic, you need to provide the view. The seismic service accepts None (which takes a view on the entire seismic store), grid layouts (in the VolumeDef format), and polygons (which cut the seismic store).

[ ]:
# Entire seismic store
client.seismic.create(
    external_id="seismic-from-none",
    name="optional name",
    # Partition identifier can be either an ID (integer) or an external id (string)
    partition_identifier=partition.external_id,
    seismic_store_id=store.id,
    metadata = {
        "optional": "metadata",
        "other": "metadata",
    },
)
[ ]:
# Via volumedef literal
volumedef = """
{
    "version": 102,
    "direction": "inline",
    "lines": {
   },
}
"""
client.seismic.create(
    external_id="seismic-from-volumedef",
    partition_identifier=partition.external_id,
    seismic_store_id=store.id,
    volumedef=volumedef,
    metadata = {
        "optional": "metadata",
        "other": "metadata",
    },
)
[ ]:
# Via geometry
from cognite.seismic import Geometry
## Wkt
geometry = Geometry(wkt="POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))", crs="epsg:4326")

## GeoJSON
geojson = {"type": "Feature","properties":{},"geometry": {"type": "Polygon","coordinates": [[[100.0, 0.0],[101.0, 0.0],[101.0, 1.0],[100.0, 1.0],[100.0, 0.0]]]}}

geometry = Geometry(geojson=geojson)

client.seismic.create(
    external_id="seismic-from-polygon",
    partition_identifier=partition.external_id,
    seismic_store_id=store.id,
    geometry=geometry,
)

Searching seismics

Similar to partitions, you can search seismics by id, external id, external id substring, name, or name substring. Unlike partitions, not all data is retrieved by default and must be specified.

[ ]:
client.seismic.search(
    # One of the below options.
    #   id = <int>
    #   external_id = <string>
    #   external_id_substring = <string>
    #   name = <string>
    #   name_substring = <string>
    # The following are data inclusion options and are all optional and default to falsey values.
    include_text_header=True,
    include_binary_header=True,
    include_line_range=False,
    include_volume_definition=False,
    include_seismic_store=False,
    include_partition=False,
    # Can also retrieve coverage.
    coverage_crs="epsg:4326",
    coverage_format="wkt"
)
[ ]:
# Alternatively, you can use seismics.get() to retrieve a specific seismic and, by default, all of its details except coverage.
client.seismic.get(
    external_id="testtest"
)
# To get coverage, specify the required information.
client.seismic.get(
    external_id="testtest",
    coverage_crs="epsg:4326",
    coverage_format="wkt"
)
[26]:
# You can access seismic data through its members:
seismic = client.seismic.get(id=6796337501824063)
print(
    seismic.id,
    seismic.external_id,
    seismic.text_header,
    seismic.binary_header,
    # and so on. Refer to the API Types documentation
)
6796337501824063 skyskyskyskyskyskytest1 TextHeader<C 1 DATE: 2016-09-19
C 2 AN INCREASE IN AMPLITUDE EQUALS AN INCREASE IN ACOUSTIC IMPEDANCE
C 3 Written by libsegyio (python)
C 4
C 5
C 6
C 7
C 8
C 9
C10
C11 TRACE HEADER POSITION:
C12   INLINE BYTES 189-193    | OFFSET BYTES 037-041
C13   CROSSLINE BYTES 193-197 |
C14
C15 END EBCDIC HEADER
C16
C17
C18
C19
C20
C21
C22
C23
C24
C25
C26
C27
C28
C29
C30
C31
C32
C33
C34
C35
C36
C37
C38
C39
C40                                                                             > BinaryHeader<traces: 25, trace_data_type: 5, fixed_length_traces: 0, segy_revision: 0, auxtraces: 0, interval: 4000, interval_original: 0, samples: 50, samples_original: 0, ensemble_fold: 0, vertical_sum: 0, trace_type_sorting_code: 0, sweep_type_code: 0, sweep_frequency_start: 0, sweep_frequency_end: 0, sweep_length: 0, sweep_channel: 0, sweep_taper_start: 0, sweep_taper_end: 0, sweep_taper_type: 0, correlated_traces: 0, amplitude_recovery: 0, original_measurement_system: 0, impulse_signal_polarity: 0, vibratory_polarity_code: 0>

Retrieving data from seismics

Seismics function almost identically to seismic stores for purposes of retrieving trace data. They use the same volume endpoint with slightly different parameters.

[27]:
# Can retrieve inline/xline ranges similarly to seismic stores
inline_range = seismic.volume_def.common_inline_range()
xline_range = seismic.volume_def.common_xline_range()
print(inline_range, xline_range)
RangeInclusive(1, 5, 1) RangeInclusive(20, 24, 1)
[ ]:
# Retrieving volumes is nearly identical
volume = client.volume_seismic.get_volume(id=seismic.id, inline_range=inline_range, xline_range=xline_range)
# Can also retrieve by seismic external id
volume = client.volume_seismic.get_volume(external_id=seismic.external_id, inline_range=inline_range, xline_range=xline_range)