The following files can be used to call the MFT library from 'Python'.
MFT23.py: the library of algorithms,
The programs test_MFT.py (fluxes and height adjustment) can be used to test the installation. The input data in testdata_MFT.dat (the first matrix in the file) can be used to verify that the code is working. The same file has output data from test_MFT.py in the 2nd matrix in the file.
testdata_MFT.dat: input and output data for the test_MFT program.
stability_analysis_CD.py: program for plotting the drag coefficient as a function of wind speed for a set of air-sea temperature differences. This code allows the user to easily examine how different parameterizations and/or the inclusion of physical processes influences the drag coeffient.
stability_analysis_CH.py: program for plotting the heat transfer coefficient as a function of wind speed for a set of air-sea temperature differences. This code allows the user to easily examine how different parameterizations and/or the inclusion of physical processes influences the heat transfer coeffient.
This code is designed for Linux systems, and might have to be modified for other platforms. The test_MFT program can be used to check for compiler related changes in output. The test_MFT code also demonstrates how to call the main MFT routines. The test_MFT program reads in data from the file testdata_MFT.dat, and outputs to the screen. This output should match the second table in the file testdata_MFT.dat.
It is a lot easier to program if you have examples, and even better if you can cut and paste. These examples are taken from the test_MFT codes.
from __future__ import print_function from MFT23.py import * import sys flux_model = -1 #BVW model=0; negative numbers use the options below z0_mom_prm = 6 # https://www.coaps.fsu.edu/~bourassa/MFT_html/ht_adj_docs.php#z0_mom_prm z0_TQ_prm = 1 # https://www.coaps.fsu.edu/~bourassa/MFT_html/ht_adj_docs.php#z0_TQ_prm stable_prm = 3 # https://www.coaps.fsu.edu/~bourassa/MFT_html/ht_adj_docs.php#stable_prm warn = 0 #warning are given for 1, and are hidden for 0 eqv_neut = 0 #output winds are winds rather than equivalent neutral winds z_wanted = 10.0 #height to which winds, potential temp, and humidity are adjusted Qnet = 5.0 # not used (in development for cool skin layer) sst_prm = 0 # not used (in development for cool skin layer) oil_fract_area = 0.0 # Fraction of surface covered by oil z_over_L = 0.0 zo_m = [0.0000, 0.0000] sfc_current1 = 0.0 sfc_current2 = 0.0 missing = -9999.0 try: data_file = open("testdata12.dat", "r") except IOError: print("Could not read file.") sys.exit() data_file.readline() print( "run U |ustar| ustar1 ustar2 tstar qstar zref/L cp wa Hsig tau1 tau2 shf lhf u(z) v(z) t(z) q(z) z0") for x in range(0,62): data_in_row = data_file.readline().split() for a in [2, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16]: data_in_row[a] = float(data_in_row[a]) for b in [0, 1, 4, 6, 8, 17]: data_in_row[b] = int(data_in_row[b]) if len(data_in_row) == 18 : num, dyn_in_prm, dyn_in_val, dyn_in_val2, ss_prm, ss_val, air_moist_prm, air_moist_val, sfc_moist_prm, sfc_moist_val, t_skin, t_air, ref_ht_wind, ref_ht_tq, pressure, salinity, CONVECT, astab = data_in_row count, shf, lhf, tau, u_star, t_star, q_star, z_over_L, wave_age, dom_phase_spd, hsig, zo_out, u_at_z, t_at_z, q_at_z = MFT_fluxes( dyn_in_prm, dyn_in_val, dyn_in_val2, sfc_current1, sfc_current2, CONVECT, pressure, air_moist_prm, air_moist_val, sfc_moist_prm, sfc_moist_val, salinity, ss_prm, ss_val, t_air, sst_prm, t_skin, ref_ht_wind, ref_ht_tq, z_wanted, astab, eqv_neut_prm, Qnet, warn, flux_model, z0_mom_prm, z0_TQ_prm, stable_prm, oil_fract_area, z_over_L, zo_m, missing ) if count <= 1 : print("non-convergence:" ) print( "%2i %5.2f %6.3f %6.3f %6.3f %7.4f %9.6f %8.5f %6.2f %6.2f %5.2f %6.3f %6.3f %6.2f %6.2f %6.2f %6.2f %6.3f %8.6f" (x+1, dyn_in_val, m.sqrt( u_star[0] * u_star[0] + u_star[1] * u_star[1] ), u_star[0], u_star[1], t_star, q_star, z_over_L, dom_phs_spd, wave_age, h_sig,tau[0], tau[1], shf, lhf, u_at_z[0], u_at_z[1], t_at_z, q_at_z, zo_out), sep="")
Status: ht_adj and MFT_fluxes are appear to be robust for fluxes, but there are a few combinations of options that don't work together. That wave output is clearly wrong (it will be fixed in a future update).
Warnings:
1) There are very few checks on the range of input parameters: unbelievable input will result in unbelievable output and/or crash the code. I plan to make the code more robust to bad input.
2) Use the output count. If it is zero or less, there is a problem. In some cases the fluxes are near zero, but in other cases they are grossly unreliable.
3) Taylor and Yelland parameterization is based on questionable assumptions about sea state.
Last update: 22 Sept. 2023