{ "cells": [ { "cell_type": "markdown", "id": "9354cae8-0679-4675-9bc7-8c47174d786a", "metadata": {}, "source": [ "# 2. Basic operations" ] }, { "cell_type": "markdown", "id": "617307f5-5372-4bef-93bd-2c074a5c4a26", "metadata": {}, "source": [ "Overview of basic library operations and options." ] }, { "cell_type": "code", "execution_count": null, "id": "26aedccb-c705-4891-b5aa-938d4f4024b0", "metadata": {}, "outputs": [], "source": [ "from pyswapp import *" ] }, { "cell_type": "markdown", "id": "6abce062-e84a-4b74-a3b0-62da421de112", "metadata": {}, "source": [ "### 1. Set the directories" ] }, { "cell_type": "code", "execution_count": null, "id": "0a8b3eea-1ce7-4db3-bd84-155ae16ca558", "metadata": {}, "outputs": [], "source": [ "prj_dir = '../../data/syn_data' # project directory\n", "path2raw = os.path.join(prj_dir,'raw') # path to raw data\n", "path2geom = f'{prj_dir}/geometry.csv' # path to the geometry file" ] }, { "cell_type": "markdown", "id": "cfa33a6f-e36e-4784-bd55-e46e6a819169", "metadata": {}, "source": [ "### 2. User defined settings for processing and plotting" ] }, { "cell_type": "code", "execution_count": null, "id": "d69b7074-fba1-460b-9a3e-02ffba530615", "metadata": {}, "outputs": [], "source": [ "settings = create_settings(fmin=1, fmax=100, # frequency range\n", " vmin=10, vmax=1000, velstep=1) # testing phase velocity range and step" ] }, { "cell_type": "markdown", "id": "63dd435d-ec21-45ee-a6c5-ae710ade642d", "metadata": {}, "source": [ "Full list of controllable parameters and their default values:\n", "\n", "- zero_padding = False # bool, add zeros to increase signal length\n", " \n", "- freq_step=1 # int, desired frequency step for zero padding\n", " \n", "- normalize = True # bool, normalize amplitudes\n", " \n", "- local_max = True # bool, normalize each trace based on local maximum\n", " \n", "- fmin=0 # float, minimum frequency to analyse\n", " \n", "- fmax=100 # float, maximum frequency to analyse\n", " \n", "- vmin=100 # float, minimum testing velocity\n", " \n", "- vmax=1000 # float, maximum testing velocity\n", " \n", "- velstep=1 # float, velocity increment\n", " \n", "- SFR_time = 2 # float, time for computing swept-frequency record (SFR)\n", " \n", "- kmin = 0 # float, minimum wavenumber\n", " \n", "- kmax = None # float, maximum wavenumber\n", " \n", "- normalize_power = True # bool, normalize amplitudes\n", " \n", "- local_max_power = False # bool, normalize each trace based on local maximum\n", "\n", "- window_length = 10 # int, spatial window length\n", "\n", "- window_min_offset = -np.inf # float, minimum offset to exclude near-field\n", "\n", "- window_max_offset = np.inf # float, maximum offset to exclude near-field\n", "\n", "- window_move_increment = 1 # int, move increment of spatial window" ] }, { "cell_type": "markdown", "id": "a43ffe50-2f9e-47ea-a42f-37a7ce93679d", "metadata": {}, "source": [ "### 3. Base Manager Operations" ] }, { "cell_type": "markdown", "id": "0bae7ad5-5322-4421-beef-be3389c134af", "metadata": {}, "source": [ "The BaseManager class can be called specifically to inspect a single data set. Although not its intended application, the class can also be used to manually, one by one, apply data processing to multiple shot files. It is, however, recommended to use the tailored 2D manager classes for 2D processing. Below, basic operations are showcased that can also be performed with the 2D managers." ] }, { "cell_type": "markdown", "id": "be184789-f29f-42b4-b62c-4dd8d0e740c4", "metadata": {}, "source": [ "#### 3.1 Create a new project" ] }, { "cell_type": "markdown", "id": "628f78a7-68bc-48c0-bf3e-6f62d3642f4f", "metadata": {}, "source": [ "Create a new project from scratch" ] }, { "cell_type": "code", "execution_count": null, "id": "a0f2894b-637a-4a36-88fa-3a55b479997d", "metadata": {}, "outputs": [], "source": [ "swam = BaseManager(f'{prj_dir}/proc/1_basics', # project directory path\n", " path2raw=path2raw, # optional, copy & per default rename data from path (outside project directory)\n", " path2geom=path2geom, # optional, copy geom from path (outside project directory)\n", " settings=settings, # optional, define settings for visualisations and processing\n", " rename = False, # optional, rename copied raw data to preferred filename format (Shotfile_), default value is False!\n", " overwrite = False, # optional, overwrite database .db file if it already exists --> create new project data base\n", " )" ] }, { "cell_type": "markdown", "id": "55db6aa1-e1d9-43a8-ad12-9f02b37cc633", "metadata": {}, "source": [ "#### 3.2 Load a project" ] }, { "cell_type": "markdown", "id": "2c4aa6d3-472a-43f4-ad47-5d850e723e04", "metadata": {}, "source": [ "Load an existing project" ] }, { "cell_type": "code", "execution_count": null, "id": "86204c96-2c1d-40c3-a716-d9119d2d717f", "metadata": {}, "outputs": [], "source": [ "swam = BaseManager(f'{prj_dir}/proc/1_basics') # project directory path" ] }, { "cell_type": "markdown", "id": "fc9ed40f-f0bf-42d8-b1a6-a2ed147cb370", "metadata": {}, "source": [ "#### 3.3 Load/select data" ] }, { "cell_type": "markdown", "id": "95579d51-854d-4a16-8177-1902ac61eeaf", "metadata": {}, "source": [ "3.3.1 load data from database based on existing procset label" ] }, { "cell_type": "code", "execution_count": null, "id": "bedfda32-2301-4352-a048-c21b23a5fb98", "metadata": {}, "outputs": [], "source": [ "swam.load_procset('raw')" ] }, { "cell_type": "markdown", "id": "d6ea4363-b6c3-43a3-a4f9-2be6c0cd3dea", "metadata": {}, "source": [ "3.3.2 Set a new procset label" ] }, { "cell_type": "code", "execution_count": null, "id": "ab66a0e5-4c35-49b3-9247-e53a4ca6972f", "metadata": {}, "outputs": [], "source": [ "swam.set_procset_label('proc_new')" ] }, { "cell_type": "markdown", "id": "bc86fb11-f601-4539-99e2-2acba8a19c23", "metadata": {}, "source": [ "3.3.3 Select a shot file" ] }, { "cell_type": "code", "execution_count": null, "id": "62cbcb02-daa7-4c7a-b7f7-938dc71b2cf3", "metadata": {}, "outputs": [], "source": [ "swam.select_data(sin=1, rep=1, inplace=True)" ] }, { "cell_type": "markdown", "id": "4ba7c233-352e-4a0a-b0ff-23057a63a760", "metadata": {}, "source": [ "#### 3.4 Preprocess data" ] }, { "cell_type": "markdown", "id": "8005d33a-dab0-4161-897e-a962637a6079", "metadata": {}, "source": [ "Apply one or several pre-processing options to the data" ] }, { "cell_type": "markdown", "id": "1c34fddc-2dca-4ca6-8ee3-2d73f6a020ce", "metadata": {}, "source": [ "3.4.1 Trimming" ] }, { "cell_type": "code", "execution_count": null, "id": "3c9760c8-a311-450a-a430-3fbb9b15a591", "metadata": {}, "outputs": [], "source": [ "# Cut traces outside of offset limits considering forward, reverse or both offset shots\n", "swam.preprocess(type = 'trim', by = 'offset', min = 5, max = 48, which = 'both')" ] }, { "cell_type": "code", "execution_count": null, "id": "cdb363eb-25e3-4e48-a139-3923503297ca", "metadata": {}, "outputs": [], "source": [ "# Cut recording time based on top and bottom cut-off values (min and max, respectively)\n", "swam.preprocess(type = 'trim', by = 'time', min = 0, max = 0.5)" ] }, { "cell_type": "code", "execution_count": null, "id": "e387e57b-11f9-4540-81ac-289b61eab4ed", "metadata": {}, "outputs": [], "source": [ "# Select traces with specified geophone separation of dx (in the unit of the data)\n", "swam.preprocess(type = 'trim', by = 'separation', dx=2)" ] }, { "cell_type": "code", "execution_count": null, "id": "6da939ec-bb91-4d2d-8f5a-f5a89f9b06db", "metadata": {}, "outputs": [], "source": [ "# Select traces within a window defined by window midpoint (xmid) and window length (number of traces)\n", "swam.preprocess(type = 'trim', by = 'window', xmid = 25, wlen = 20)" ] }, { "cell_type": "code", "execution_count": null, "id": "a15558c2-a7f8-4a7a-bb7e-45d8fd5dc95b", "metadata": {}, "outputs": [], "source": [ "# Select traces\n", "swam.preprocess(type = 'trim', by = 'select', trace_ids = [1,2,3])" ] }, { "cell_type": "code", "execution_count": null, "id": "dfb4cd9f-94eb-4a94-81d5-c76d2f4924a5", "metadata": {}, "outputs": [], "source": [ "# Remove traces\n", "swam.preprocess(type = 'trim', by = 'remove', trace_ids = [1,2,3])" ] }, { "cell_type": "markdown", "id": "68574c1e-19da-43ea-806d-2a5200280ad9", "metadata": {}, "source": [ "3.4.2 Filtering" ] }, { "cell_type": "code", "execution_count": null, "id": "608a5773-8723-43b0-a7dd-c46c1fbd4274", "metadata": {}, "outputs": [], "source": [ "# Apply bandpass, lowpass or highpass frequency filtering\n", "swam.preprocess(type = 'filter', by = 'frequency', min = 5, max = 20, filter_type = 'bandpass')" ] }, { "cell_type": "code", "execution_count": null, "id": "0b83ebde-5300-44a7-9ca9-754c59c3686d", "metadata": {}, "outputs": [], "source": [ "# Apply linear move-out with specified velocity\n", "swam.preprocess(type = 'filter', by = 'lmo', velocity = 100, bulk_shift = 0)" ] }, { "cell_type": "code", "execution_count": null, "id": "a47c56d5-ce2d-4221-a314-fe828d6a01b2", "metadata": {}, "outputs": [], "source": [ "# Mute amplitudes of selected traces\n", "swam.preprocess(type = 'filter', by = 'mute', trace_ids = [1,2,3])" ] }, { "cell_type": "code", "execution_count": null, "id": "b9285bac-147b-4466-b433-38a5f43b3196", "metadata": {}, "outputs": [], "source": [ "# Reverse polarity of selected traces\n", "swam.preprocess(type = 'filter', by = 'reverse_polarity', trace_ids = [1,2,3])" ] }, { "cell_type": "code", "execution_count": null, "id": "89a6a902-6036-47db-a7fb-1d59286c3856", "metadata": {}, "outputs": [], "source": [ "# Apply Hamming window\n", "swam.preprocess(type = 'filter', by = 'taper')" ] }, { "cell_type": "code", "execution_count": null, "id": "d9439652-fa25-47fd-bf7b-b734039dadc7", "metadata": {}, "outputs": [], "source": [ "# Filter in FK based on a file containing the filter (points along line to mute data abov or below)\n", "swam.preprocess(type='filter', by = 'FK', fname = 'FKfilter.txt')" ] }, { "cell_type": "markdown", "id": "423d902c-5325-40d0-a812-b31bab2d3563", "metadata": {}, "source": [ "3.3.3 Import/export filter for whole database" ] }, { "cell_type": "code", "execution_count": null, "id": "653f95ec-02f9-4df5-9b57-65a6793d70c2", "metadata": {}, "outputs": [], "source": [ "# save picked filter from database to disk for whole procset \n", "swam.save_filter(fname = 'filter.csv', ftype='FK')" ] }, { "cell_type": "code", "execution_count": null, "id": "092972dc-11ce-4602-8eb3-ecf7c4eb247f", "metadata": {}, "outputs": [], "source": [ "# import filter from disk for whole procset and add to database\n", "swam.import_filter(fname = 'filter.csv')" ] }, { "cell_type": "code", "execution_count": null, "id": "e7c2b34a-4c50-458c-a239-281441d17244", "metadata": {}, "outputs": [], "source": [ "# apply filter to data for whole procset\n", "swam.apply_filter(ftype='FK')" ] }, { "cell_type": "markdown", "id": "1077a9d9-3bbd-4f19-96f6-a4192ab04c41", "metadata": {}, "source": [ "3.4.4 MISC" ] }, { "cell_type": "code", "execution_count": null, "id": "b92af8c1-242c-46ef-97f3-b8ef61b519bc", "metadata": {}, "outputs": [], "source": [ "# remove traces of zero amplitude\n", "swam.preprocess(type='check_traces')" ] }, { "cell_type": "markdown", "id": "b9ec30eb-6526-4a4b-a7e6-6714597abffc", "metadata": {}, "source": [ "### 4. Wave-field transformations" ] }, { "cell_type": "markdown", "id": "688eadb5-c373-4caa-8f9d-ef851d666616", "metadata": {}, "source": [ "Perform wavefield transformation based on the phaseshift, fdbfm or radon transform" ] }, { "cell_type": "code", "execution_count": null, "id": "840be072-94a4-49e6-8960-43d8591970c6", "metadata": {}, "outputs": [], "source": [ "swam.transform(method = 'phaseshift')" ] }, { "cell_type": "code", "execution_count": null, "id": "b8a3054a-ebd1-43cc-a487-cc15c2abdd02", "metadata": {}, "outputs": [], "source": [ "swam.transform(method = 'fdbf')" ] }, { "cell_type": "markdown", "id": "5700e0f0-905e-4017-a145-8f9ad69cd724", "metadata": {}, "source": [ "### 5. Automatic dispersion curve extraction" ] }, { "cell_type": "markdown", "id": "119c8203-cd5c-467a-9fe4-da592b7a714d", "metadata": {}, "source": [ "Automatically extract dispersion curves based on maximum amplitudes or mopa" ] }, { "cell_type": "code", "execution_count": null, "id": "3cde7a92-beb9-44aa-9e07-5fc0763f01c2", "metadata": {}, "outputs": [], "source": [ "# automatic dispersion curve extraction using max\n", "swam.extract(method = 'max')" ] }, { "cell_type": "code", "execution_count": null, "id": "44697da4-af71-4bf6-8e44-3b010e899c54", "metadata": {}, "outputs": [], "source": [ "# automatic dispersion curve extraction using MOPA\n", "swam.extract(method = 'MOPA', stopAtChi2 = 1, abs_err = 0.01, showResults = True)" ] }, { "cell_type": "markdown", "id": "bd553d78-04d4-40fa-9a0b-6950190cf9c8", "metadata": {}, "source": [ "### 6. Save dispersion curves" ] }, { "cell_type": "markdown", "id": "49c14726-ffb7-44bb-ba5a-3df7622edb33", "metadata": {}, "source": [ "Save dispersion curves for each method to disk" ] }, { "cell_type": "code", "execution_count": null, "id": "698a8cb4-5222-4b13-9f96-85cbed8b6ff4", "metadata": {}, "outputs": [], "source": [ "# save the manually picked dispersion curves in dispersion images\n", "swam.save(method = 'fdbf')\n", "swam.save(method = 'phaseshift')\n", "swam.save(method = 'radon')" ] }, { "cell_type": "code", "execution_count": null, "id": "37f94bca-5c7d-499b-bc00-1440ead12332", "metadata": {}, "outputs": [], "source": [ "# save the automatically extracted dispersion curves\n", "swam.save(method = 'MOPA')\n", "swam.save(method = 'max')" ] }, { "cell_type": "markdown", "id": "758ded9b-26d4-4d42-97c3-360778fc23e0", "metadata": {}, "source": [ "### 7. Plotting " ] }, { "cell_type": "code", "execution_count": null, "id": "01f030cd-237e-4f52-b375-18b2b82b490c", "metadata": {}, "outputs": [], "source": [ "swam.plot('geometry')" ] }, { "cell_type": "code", "execution_count": null, "id": "4f59becd-976b-4f7b-b81a-cd1aa7c085ec", "metadata": {}, "outputs": [], "source": [ "swam.plot('seismogram', amp_scale = 1, color = 'k')" ] }, { "cell_type": "code", "execution_count": null, "id": "9a97a961-9c44-43c2-a4fa-74f22943ee74", "metadata": {}, "outputs": [], "source": [ "swam.plot('FK')" ] }, { "cell_type": "code", "execution_count": null, "id": "2de11bd7-c2b0-4801-9f1f-5da12a46072b", "metadata": {}, "outputs": [], "source": [ "swam.plot('spectra')" ] }, { "cell_type": "code", "execution_count": null, "id": "5607cb8f-9a79-4fb7-b7f8-03bebffe481b", "metadata": {}, "outputs": [], "source": [ "swam.plot('spectrogram')" ] }, { "cell_type": "code", "execution_count": null, "id": "0f6dcb6f-dd3e-4334-90f8-d2a2bceee4f0", "metadata": {}, "outputs": [], "source": [ "swam.plot('FV', method = 'phaseshift')" ] }, { "cell_type": "code", "execution_count": null, "id": "c622ebac-a17f-4b54-af27-75945b949e70", "metadata": {}, "outputs": [], "source": [ "swam.plot('FV', method = 'fdbf')" ] }, { "cell_type": "code", "execution_count": null, "id": "0376dbbd-2145-4afb-a969-8f419dc7acb0", "metadata": {}, "outputs": [], "source": [ "swam.plot('pseudosection', method = 'MOPA')" ] }, { "cell_type": "code", "execution_count": null, "id": "325be60c-172f-4ae4-b64d-4c763409e3ae", "metadata": {}, "outputs": [], "source": [ "swam.plot('curve', method = 'max')" ] }, { "cell_type": "markdown", "id": "132fed9a-59e6-4be2-aa92-bb69bdb96e7d", "metadata": {}, "source": [ "### 8. GUI" ] }, { "cell_type": "code", "execution_count": null, "id": "ab81ac27-5e19-4fab-981c-ac2e5dff48a6", "metadata": {}, "outputs": [], "source": [ "# Data viewer\n", "swam.gui_view()" ] }, { "cell_type": "code", "execution_count": null, "id": "f1356118-5f3a-4554-8a16-e6bca89f9672", "metadata": {}, "outputs": [], "source": [ "# filter data in TX-domain\n", "swam.gui_interact('filter',domain = 'TX')" ] }, { "cell_type": "code", "execution_count": null, "id": "25605297-0d8a-4f79-8780-04efa4a4217c", "metadata": {}, "outputs": [], "source": [ "# filter data in FK-domain\n", "swam.gui_interact('filter',domain = 'FK')" ] }, { "cell_type": "code", "execution_count": null, "id": "5d5c55cf-4e2e-4fe0-98bf-4c8e50596f61", "metadata": {}, "outputs": [], "source": [ "# pick dispersion curves (in FV or FK domain)\n", "swam.gui_interact('pick')" ] } ], "metadata": { "kernelspec": { "display_name": "pyswapp", "language": "python", "name": "pyswapp" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.23" } }, "nbformat": 4, "nbformat_minor": 5 }