
# Function to find the column name in the Well Logs Dataframe
def find_column(df, curve_type):
    """
    Function to find the column name in the Well Logs Dataframe
    args:
        df: Well Logs Dataframe
        curve_type: curve type
    returns:
        column name

    """
    df_columns_lower = {col.lower(): col for col in df.columns}
    for mnemonic in mnemonic_dict[curve_type]:
        if mnemonic.lower() in df_columns_lower:
            return df_columns_lower[mnemonic.lower()]
    return None



# Function that create the mnemonic dictionary
def create_mnemonic_dict(
    gamma_names,
    sp_names,
    caliper_names,
    deepres_names,
    rxo_names,
    density_names,
    density_correction_names,
    neutron_names,
    dtc_names,
    dts_names,
    pe_names,
):
    mnemonic_dict = {
        "gamma": gamma_names,
        "sp": sp_names,
        "caliper": caliper_names,
        "deepres": deepres_names,
        "rxo": rxo_names,
        "density": density_names,
        "density_correction": density_correction_names,
        "neutron": neutron_names,
        "dtc": dtc_names,
        "dts": dts_names,
        "pe": pe_names,
    }
    return mnemonic_dict


# For gamma ray logs
gamma_names = [
    "gr",
    "cggr",
    "cgr",
    "dlgr",
    "ecgr",
    "ehgr",
    "hrgr",
    "gam",
    "gamd",
    "gamm",
    "gamma",
    "gammaray",
    "gamnat",
    "gcgr",
    "gcps",
    "gra",
    "gray",
    "grc",
    "grcd",
    "grcf",
    "grd",
    "grde",
    "grdi",
    "grg",
    "grgc",
    "grgm",
    "grgm",
    "grgs",
    "grh",
    "grhd",
    "grhdil",
    "gri",
    "grin",
    "grll",
    "grm",
    "grml",
    "grn",
    "grnc",
    "grnp",
    "grp",
    "grpd",
    "grpnd",
    "grqh",
    "grs",
    "grsd",
    "grsg",
    "grsl",
    "grt",
    "grto",
    "grx",
    "grz",
    "gsgr",
    "hgr",
    "hsgr",
    "lgr",
    "p01lgr",
    "p02lgr",
    "p03lgr",
    "p06lgr",
    "pgr",
    "sgr",
    "sgra",
    "sgrb",
    "sgrc",
    "rgr",
    "hcgr",
    "gamma_ray",
    "gams",
    "grcr",
    "grhr",
    "grqa",
    "grr",
    "grv",
    "mcgr",
    "grcn",
    "grdp",
    "grcc",
    "grcg",
    "grcl",
    "grcm",
    "grcp",
    "grd4",
    "grfb",
    "grmn",
    "grnb",
    "grpo",
    "grpr",
    "grrf",
    "tgr",
    "totgr",
    "grtor",
    "gr1",
    "gr2",
    "grco",
    "grda",
    "grzd",
    "hhgr",
    "mgr",
    "sgrd",
    "ipgr",
    "idgr",
    "gr_stgc",
    "gr_edtc_s",
    "gradx",
    "grarfm"
]

# For spontanous potential logs
sp_names = [
    "SP",
    "IDSP",
    "SPR",
    "SPL",
    "SPDL",
    "SPDHP",
    "SPDH",
    "SPDF",
    "SPD",
    "SPCG",
    "SPC",
    "SP0",
    "SP1",
    "SPBR",
    "SPBRDH",
    "IASP",
    "CGSP",
    "DLSP",
    "SPLL",
]

# For caliper logs
caliper_names = [
    "CALIPER",
    "CALIP",
    "CALI",
    "CAL",
    "DCAL",
    "ACAL",
    "CALA",
    "CALD",
    "CALE",
    "CALH",
    "CALL",
    "CALM",
    "CALML",
    "CALN",
    "CALP",
    "CALS",
    "CALT",
    "CALX",
    "CALXH",
    "CALXZ",
    "CALY",
    "CALYH",
    "CALYHD",
    "CALYM",
    "CALYQH",
    "CALYZ",
    "CALZ",
    "CANC",
    "CANN",
    "CAPD",
    "CAX",
    "CAY",
    "CLDC",
    "CLDM",
    "CLL0",
    "CLMR",
    "CLMS",
    "CLRM",
    "CLS2",
    "CLTC",
    "CLXC",
    "CLXF",
    "CLYC",
    "MCAL",
    "CALXQH",
    "CLCM",
    "CR1",
    "CR2",
    "CS1M",
    "CS2M",
    "CS3M",
    "CS4M",
    "CS5M",
    "CS6M0",
    "HCA1",
    "HCAL",
    "HCALI",
    "HCALX",
    "HCALY",
    "XCAL",
    "YCAL",
    "CABX",
    "CABY",
    "CACN",
    "CADF",
    "CADP",
    "CAMR",
    "CAXR",
    "CAYR",
    "DCCP",
    "MLTC",
    "C1",
    "C13",
    "C13A",
    "C13H",
    "C24A",
    "C24",
    "C24H",
    "C24I",
    "C24L",
    "C24M",
    "C24P",
    "C24Z",
    "CA",
    "CA1",
    "CA2",
    "CADE",
    "CAL1",
    "CAL2",
    "CAL3",
    "CALXM",
    "CALXQ8",
    "CALXGH",
    "CALYQ8",
    "CLCD",
    "CLLO",
    "CQLI",
    "HD1",
    "HD2",
    "HD3",
    "HDAR",
    "HDIA",
    "HDMI",
    "HDMN",
    "HDMX",
    "HLCA",
    "LCAL",
    "SA",
    "TAC2",
    "C3",
    "HHCA",
    "MBTC",
    "TACC",
    "DZAL",
]

# For deep resistivity logs
deepres_names = [
    "RT",
    "RTAO",
    "RT1DI",
    "RT90",
    "ILD",
    "IDER",
    "IDFL",
    "IDID",
    "IDPH",
    "IDVR",
    "ILS",
    "RILD",
    "RIPD",
    "RILV",
    "RD",
    "DEEP",
    "AE90",
    "AF90",
    "AHFRT",
    "AHO90",
    "AHORT",
    "AHRT",
    "AHT90",
    "AHTRT",
    "AIRD",
    "AO90",
    "AORT",
    "AS90",
    "ASF90",
    "ASFRT",
    "ASRT",
    "AST90",
    "ASTRT",
    "AT90",
    "ATRT",
    "DSER",
    "HILD",
    "HLLD",
    "HRLD",
    "LLD",
    "LLDC",
    "VRSD",
    "SEDC",
    "SEDA",
    "RLLD",
    "RES",
    "RESD",
    "REID",
    "DLL",
    "DDLL",
    "HDRS",
    "R850",
    "MINV",
    "ML",
    "M1R9",
    "R60O",
    "M2RX",
]

# For Shallow Resistivity Logs
rxo_names = ["RXO", "RXOZ", "MSFL", "MCFL", "SFLCC", "MGL", "M1RX", "R40O", "AHT10"]

# For density logs
density_names = [
    "RHOB",
    "RHOZ",
    "DEN",
    "DENB",
    "DENC",
    "DENCDL",
    "HRHO",
    "HRHOB",
    "ZDEN",
    "ZDENS",
    "ZDNCS",
    "ZDNC",
    "HDEN",
    "DENF",
    "DENN",
    "RHS",
]

# For density correction
density_correction_names = [
    "DCOR",
    "DCORR",
    "DC",
    "DECR",
    "DRH",
    "ZCOR",
    "ZCORR",
    "ZCOR2",
    "ZCOR2QH",
    "ZCORQH",
    "HHDR",
    "DensCorr",
]

# For neutron logs
neutron_names = [
    "CN",
    "PHIN",
    "CNC",
    "CNS",
    "HHNPO",
    "HNPHI",
    "NPHI",
    "NPOR",
    "CNCC",
    "CNCD",
    "CNCF",
    "NPRL",
    "TNPH",
    "TPHC",
    "XPOR",
    "NEUT",
    "NeutPor",
    "NPHIL",
    "CNFC",
]

# For photoelectric factor logs
pe_names = [
    "PE",
    "PEF",
    "PEFZ",
    "PDPE",
    "PEDF",
    "PEDN",
    "HPEDN",
    "HPEH8",
    "PE2",
    "PE2QH",
    "PEF8",
    "PEFA",
    "PEFI",
    "PEFL",
    "LPE",
    "PEFS",
]

# For P wave sonic travel time
dtc_names = [
    "DT",
    "DTC",
    "DTCO",
    "DTCOMP",
    "DELTAT",
    "SLOW",
    "SLOWNESS",
    "TT",
    "TIME",
    "TIM",
    "ITT",
    "DTCQI",
    "DTCR",
    "DTCREP",
    "DTCS",
    "DTCSG",
    "DTCU",
    "DTCV0",
    "DTCX",
    "DTL",
    "DTP",
    "DTR",
    "DTTP",
    "DTU",
    "DTUM",
    "CTIME",
    "COTIME",
    "COMT",
    "DT1A",
    "DT1B",
    "DT34",
    "DT35",
    "DT3A",
    "DT3B",
    "DT45",
    "DT46",
    "DT56",
    "DTC1",
    "DTC2",
    "DTC3",
    "DTCM",
    "AC",
    "ACCO",
    "DELT",
    "ACL",
    "ACN",
    "DT24",
    "DT24QI",
    "DT24SQA",
    "DT41",
    "DT4P",
    "DT5",
    "DTMN",
    "DTMX",
    "DTSC",
    "TTC",
    "AC1",
    "MSTT",
    "DtComp",
]

# For  S wave sonic travel time
dts_names = [
    "DTS",
    "DTSH",
    "DTSM",
    "DTSC",
    "DTSD",
    "DTSDF",
    "DTSQI",
    "DTTS",
    "DTSHEAR",
    "DELTAS",
    "TTS",
    "TIMES",
    "TIMS",
    "ITTS",
    "STT",
    "DT4S",
    "DTSF",
    "DTSS",
    "SHSL",
    "DtShear",
]



mnemonic_dict = create_mnemonic_dict(
    gamma_names,
    sp_names,
    caliper_names,
    deepres_names,
    rxo_names,
    density_names,
    density_correction_names,
    neutron_names,
    dtc_names,
    dts_names,
    pe_names,
)

