OGGM / oggm

Open Global Glacier Model
http://oggm.org
BSD 3-Clause "New" or "Revised" License
224 stars 106 forks source link

process_cesm_data not suited for all CESM outputs #818

Open anoukvlug opened 5 years ago

anoukvlug commented 5 years ago

I tried with @gyjls to use the process_cesm_data function to process the 400BP-1990CE files of the CESM trace simulation. Unfortunately the function gives an error, because the files have unlike the CESM-LME no time_bnds variable.

time:bounds = "time_bnds" ;
        double time_bnds(time, nbnd) ;
 time_bnds:long_name = "time interval endpoints"
fmaussion commented 5 years ago

It should be quite easy to fix right? Do you plan to submit a fix?

anoukvlug commented 5 years ago

Yes, it should be not to complicated. I could look for a solution and submit it. Though I would prefer to first deal, with PR #814, to limit the versions I have of the code. (It is not right timing for me to start experimenting with having multiple branches at the same time ;) )

anoukvlug commented 5 years ago

I started looking into how to solve this issue. It seems like it might be less straight forward than I thought.

Here is a list of issues that I encountered so far:

@fmaussion, what do you think?

@gyjls

fmaussion commented 5 years ago

@anoukvlug thanks for looking into this.

The solution depends on the scale of the data you are looking at: the best of course would be to creat compatible files before feeding them to OGGM, i.e. by adding/correcting the files attributes once for all in simple separate notebooks.

A second way is to build all the dirty if .. then logic in a process_dirty_cesm function and use this one. In this case I'm relunctant to add this function to OGGM, but I don't see a big issue here since it is possible to use the process_gcm_data anyway.

anoukvlug commented 5 years ago

Yes, you are right. I thought 'days since ....' couldn't be negative. As they can be negative there is indeed not as much of a problem as I thought and process_gcm_data should be able to deal with these files. once they are in the proper format.

anoukvlug commented 5 years ago

I started making a notebook, to preprocess the CESM trace data and use this as climate data to run OGGM. I generated a climate file to test this and tried to use it in the run_from_climate_data function. This works fine up to going back to ~6700BP.

When going further back in time I get the error:

ValueError: julian day must be a positive integer

In the following part of the code:

with ncDataset(fpath, mode='r') as nc:
    time = nc.variables['time']
    time = netCDF4.num2date(time[:], time.units)

I am not sure how to best deal with this issue.

anoukvlug commented 5 years ago

A (ugly) work around for this issue is to:

  1. Process the data through process_gcm_data
  2. Open the gcm_data*.nc file that you generated.
  3. Increase the time variable, so you don't have dates before 4712 BC.
  4. Save the data and the shifted time with write_monthly_climate_file
  5. Use the climate file, with for instance run_from_climate_data
  6. Don't forget to shift the time back once analysing the output.