Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Terrestrial Coupling Index #45

Open
nocollier opened this issue May 24, 2023 · 1 comment
Open

Add Terrestrial Coupling Index #45

nocollier opened this issue May 24, 2023 · 1 comment

Comments

@nocollier
Copy link
Collaborator

Computed as:

CI(x) = covar( SM(t,x), SHFLX(t,x) ) / sigma(SM(t,x)

Daily averaging period matters in this case. I am curious why not normalize completely by also dividing through by sigma_SHFLX? Then you have Pearson's correlation coefficient.

We have dabbled with daily data, but nothing that has made it into something we compute regularly. It is more of an organizational problem and nothing we cannot remedy. Seasonal averaging is just not added (we haven't used it) and nothing we cannot do quickly.

I would recommend that we make a Confrontation for this. I have been long working on a new version of ILAMB based on xarray. It has just taken a long time to re-implement everything. One approach I am now using is to add new things to ILAMB in the new xarray way when possible and then create a backward compatibility wrapper to the old version. I can do this pretty quickly.

Fluxnet data is a pain to work with. The following snippet combines a few columns from the monthly data into a single dataframe and then xarray dataset with arrays that are of dimension (time, ndata). It doesn't have all the metadata yet, but you may find it useful.

DFS = []
include = ["TIMESTAMP", "SWC_F_MDS_1", "TA_F_MDS", "GPP_NT_VUT_MEAN"]
for fname in glob.glob("*FULLSET_MM*"):
    read = pd.read_excel if fname.endswith(".xlsx") else pd.read_csv
    cols = read(fname, nrows=0).columns
    if set(include).difference(cols):
        continue
    site = fname.split("_")[1]
    df = read(fname, na_values=-9999)[include]
    df = df.dropna()
    df["TIMESTAMP"] = pd.to_datetime(df["TIMESTAMP"], format="%Y%d")
    df["SITE"] = site
    df = df.set_index(["TIMESTAMP", "SITE"])
    DFS.append(df)

df = pd.concat(DFS)
ds = df.to_xarray()
ds.to_netcdf("Fluxnet2015.nc")
@nocollier
Copy link
Collaborator Author

Draft PR: rubisco-sfa/ILAMB#71

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant