Project: s41467-024-51555-8 | Function: fcst (python)

system: You are an expert Python programmer implementing algorithms from scientific papers.
Complete the masked function based on the algorithm description.
Follow Python best practices and maintain consistent code style.
Return **only** the complete Python function code.

user: Complete this Python function:

**DESCRIPTION:** Implements the core preseason crop yield forecast algorithm that combines historical ENSO-conditioned probabilities with probabilistic ENSO forecasts using hypergeometric distribution to estimate the likelihood of below-normal crop yields at long lead times (6-18 months)

**KEY TERMS:** {
  "ensoProbs": "forecast probabilities [pLN, pN, pEN] for each ENSO phase",
  "varArr": "historical crop yield anomaly data",
  "quantile": "tercile threshold (1/3) for below-normal classification",
  "hypergeom.sf": "hypergeometric survival function for statistical significance testing",
  "varProbFCST": "final forecast probability Pybn_i",
  "evYrsLN": "La Niña years for conditioning",
  "evYrsN": "Neutral years for conditioning",
  "evYrsEN": "El Niño years for conditioning"
}

**CONTEXT CODE:** #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 30 11:56:50 2021

@author: wanders7

varArr is a 3-D array of shape [Time, Space, Space]. The order of lat/lon is not important
years is a 1-D array of years that correspond to the [Time] dimension of varArr
quantile is a fraction, between 0 and 1, that defines the quantile to test
ensoProbs is a three-member array of the probability of [La Niña, Neutral, El Niño]
ensoSeas is the three-month season to use for ENSO event identification. This has to be a three month season, e.g. "MAM"
ensoLag is the offset to apply to the enso year. If you want to use OND -1 to identify effects on JFM 0 soil moisture, the ensoLag would = -1
Mode defines the climate mode to use to identify events. Only ENSO or Western V Gradient ("WVG") are options right now.
verbose is a flag that indicates whether the function should print out all the parameters

"""
import numpy as np
import pandas as pd
from scipy.stats import hypergeom
from scipy import signal

codePath = '/Users/wanders7/Documents/Code/General'
savePath1 = '/Users/wanders7/Documents/Research'
dataPath1 = '/Volumes/Svalbard'
dataPath2 = '/Volumes/Data_Archive'

ensoSeasonNames = ['DJF','JFM','FMA','MAM','AMJ','MJJ','JJA','JAS','ASO','SON','OND','NDJ']

def fcst(varArr, years, ensoProbs, quantile=0.333333333, ensoSeas='NDJ', ensoLag=0, ensoTh=0.5, mode='ENSO',verbose=False):
    """
    Forecast crop yield probability using ENSO conditioning.
    """
    # MASKED: Implements the core preseason crop yield forecast algorithm that combines historical ENSO-conditioned probabilities with probabilistic ENSO forecasts using hypergeometric distribution to estimate the likelihood of below-normal crop yields at long lead times (6-18 months)
    raise NotImplementedError("Function has been masked for testing purposes")

        

Complete the function implementation replacing "raise NotImplementedError".