FESOM / tripyview

Triangular plotting for FESOM2
MIT License
4 stars 3 forks source link

Gsw instead of seawater #128

Open JanStreffing opened 2 months ago

JanStreffing commented 2 months ago

Needs a thorough test. Not to be merged before #127

JanStreffing commented 2 months ago

Found a first problem. I think this happens in:

 --> compute hslice_clim:
     --> compute: temp
          --> compute depth: 100
papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [6]":
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 7
      5 if   vname=='temp' and  which_clim.lower()=='woa18': clim_vname = 't00an1'
      6 elif vname=='salt' and  which_clim.lower()=='woa18': clim_vname = 's00an1'
----> 7 clim = tpv.load_climatology(mesh, clim_path, clim_vname, depth=depth)
      8 print(' --> elasped time to load clim: {:3.2f} min.'.format( (clock.time()-ts)/60  ))
      9 print(' --> clim uses {:3.2f} Gb:'.format(clim.nbytes/(1024**3)))

File /work/ab0246/a270092/software/tripyview/tripyview/sub_climatology.py:69, in load_climatology(mesh, datapath, vname, depth, depidx, do_zarithm, do_hinterp, do_zinterp, descript, do_ptemp, pref, do_compute, do_load, do_persist, **kwargs)
     62     #data_depth = data[coord_zlev]
     63     #data_depth = data_depth.expand_dims({dim_lat:data[coord_lat].data,
     64                                          #dim_lon:data[coord_lon].data}
     65                                         #).transpose(dim_zlev,dim_lat,dim_lon)
     66     data_depth = data[coord_zlev].expand_dims(
     67                     dict({dim_lat:data[coord_lat].data, dim_lon:data[coord_lon].data})
     68                     ).transpose(dim_zlev,dim_lat,dim_lon)
---> 69     data[vname_temp].data = sw.ptmp(data[vname_salt].data, data[vname_temp].data, data_depth )
     71 #___________________________________________________________________________
     72 # if there are multiple variables, than kick out varaible that is not needed
     73 vname_drop = list(data.keys())

AttributeError: module 'gsw' has no attribute 'ptmp'
JanStreffing commented 2 months ago

I think it's ok to replace ptmp from https://pythonhosted.org/seawater/eos80.html with https://teos-10.github.io/GSW-Python/_modules/gsw/_wrapped_ufuncs.html#pt_from_t. We would update from EOS80 to TEOS10, which I think is good. Need to be sure this does not clash with our obs input file or FESOM2 output units. We also have to give pref=0, which used to be a default with the old function.

gsw.pt_from_t: fesom_26rc1_bugfix_hnode_hslice_clim_temp_rob_z100

sw.ptmp: fesom_26rc1_bugfix_hnode_hslice_clim_temp_rob_z100

patrickscholz commented 2 months ago

Ich hatte das vorm urlaub auch schon mal ins auge gefasst. Hab dann aber gemerkt das man da vorsichtig sein muss. Da die gsw routinen als input nicht mehr potentielle temperatur haben sondern CT conservative temperature. Wenn mann das glaub ich korrect machen will muss man da noch einen zwischen schritt einbauen mit PT --> CT. Ich wollte das ohnehin nach dem urlaub mit machen.

JanStreffing commented 2 months ago

Are you sure? There is also CT to T, but this function is specifically called PT to T. Same checks should be done for the lastest commit where I switch from sw.dens to gsw.rho.