Skip to content

Annual SPI? #25

@deborarodriguesp

Description

@deborarodriguesp

Hello!

I have 30 years of data for a watershed and want to find the wet, dry, and normal years.

For this, I am yearly summing the precipitation data. Then I want to calculate using SPI.

My question arises in frequency and scale.
Can I use freq=M and scale=12? However, this is wrong because it will use the first 12 data so the first months will be NaN...
So can I use freq=M and scale=1?
Or do I need to use freq_col? I honestly have no idea...

Thanks in advance to those who can help me!

df_yearly = df.resample('Y', on='Date').sum().reset_index() 
df_SPI = calculate_spi(df_yearly, freq_col='Year')

def calculate_spi(df_yearly,freq_col):
    spi_calculator = SPI()
    spi_results = spi_calculator.calculate(
        df_yearly,
        date_col='Date',         
        precip_cols='Total',     
        freq_col=freq_col,             
        scale=12,             
        fit_type='lmom',          
        dist_type='gam'       
    )
    return spi_results

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions