<commit_before>module AgwxBiophys
  module ET
    SOLCON    = 1367.0
    STEFAN    = (0.0864*0.0000000567)
    SFCEMISS  = 0.96
    ALBEDO    = 0.25
    KELVIN    = 273.15
    
    def rad_lat(lat); lat * Math::PI / 180.0;end

    def daily_to_sol(total_sol); 0.0864 * total_sol; end

    def declin(doy)
      0.41 * 
        Math::cos(
          2 * Math::PI * ( doy - 172.0 ) / 365.0
        )
    end

    def sunrise_angle(doy,lat)
      Math.acos(
        -1 *
        Math.tan(declin(doy)) *
        Math.tan(rad_lat(lat))
      )
    end

    def sunrise_hour(doy,lat); 12 - ( 12 / Math::PI ) * sunrise_angle(doy,lat); end

    def day_hours(doy,lat); 24 - 2 * sunrise_hour(doy,lat); end

    def av_eir(doy)
      SOLCON * ( 1 + 0.035 * Math.cos( 2 * Math::PI * doy / 365.0 ) )
    end
    
    def to_eir(doy,lat)
      ( 0.0864 / Math::PI ) * av_eir(doy) *

      (
        sunrise_angle(doy,lat) *
         Math.sin( declin(doy) ) *
         Math.sin( rad_lat(lat) ) +
         
        Math.cos( declin(doy) ) *
         Math.cos( rad_lat(lat) ) *
         Math.sin( sunrise_angle(doy,lat) )
      )
    end
    
    def c_to_k(temperature); temperature + KELVIN; end

    # Remember, temps in kelvin!
    def lwu(min_temp,max_temp)
      avg = (min_temp+max_temp) / 2.0
      SFCEMISS * STEFAN * (273.15+avg) ** 4
    end
    
    def sfactor(min_temp,max_temp)
      avg = (min_temp+max_temp) / 2.0
      0.398 + 0.0171 * avg - 0.000142 * avg * avg
    end
    
    def sky_emiss(avg_v_press,min_temp,max_temp)
      avg_temp = (min_temp+max_temp) / 2.0
      if ( avg_v_press > 0.5)
        0.7 + (5.95e-4) * avg_v_press * Math.exp( 1500/(273+avg_temp) );
      else
        (1 - 0.261*Math.exp(-0.000777*avg*avg))
      end
    end
    
    # Here's the old Java code
    # double rad_lat =       lat *Math.PI/180.0;
    # double DailyToSol =    0.0864 * DToSol;
    # double Declin =    0.41 *Math.cos( 2 * Math.PI * ( dayOfYear -172. ) / 365. );
    # double Sunrise_Angle = Math.acos( -1*Math.tan(Declin) * Math.tan(rad_lat));
    # double Sunrise_Hour = 12 - ( 12 / Math.PI ) * Sunrise_Angle;
    # double Day_Hours = 24 - 2 * Sunrise_Hour;

    # double AvEIR = SOLCON * ( 1 + 0.035 * Math.cos( 2 * Math.PI * dayOfYear / 365. ) );<commit_msg>Just putzing. Apparently didn't save the version from email after all.<commit_after>module AgwxBiophys
  module ET
    SOLCON    = 1367.0
    STEFAN    = (0.0864*0.0000000567)
    SFCEMISS  = 0.96
    ALBEDO    = 0.25
    KELVIN    = 273.15
    
    def rad_lat(lat); lat * Math::PI / 180.0;end

    def daily_to_sol(total_sol); 0.0864 * total_sol; end

    def declin(doy)
      0.41 * 
        Math::cos(
          2 * Math::PI * ( doy - 172.0 ) / 365.0
        )
    end

    def sunrise_angle(doy,lat)
      Math.acos(
        -1 *
        Math.tan(declin(doy)) *
        Math.tan(rad_lat(lat))
      )
    end

    def sunrise_hour(doy,lat); 12 - ( 12 / Math::PI ) * sunrise_angle(doy,lat); end

    def day_hours(doy,lat); 24 - 2 * sunrise_hour(doy,lat); end

    def av_eir(doy)
      SOLCON * ( 1 + 0.035 * Math.cos( 2 * Math::PI * doy / 365.0 ) )
    end
    
    def to_eir(doy,lat)
      ( 0.0864 / Math::PI ) * av_eir(doy) *

      (
        sunrise_angle(doy,lat) *
         Math.sin( declin(doy) ) *
         Math.sin( rad_lat(lat) ) +
         
        Math.cos( declin(doy) ) *
         Math.cos( rad_lat(lat) ) *
         Math.sin( sunrise_angle(doy,lat) )
      )
    end
    
    def c_to_k(temperature); temperature + KELVIN; end

    # Remember, temps in kelvin!
    def lwu(min_temp,max_temp)
      avg = (min_temp+max_temp) / 2.0
      SFCEMISS * STEFAN * (273.15+avg) ** 4
    end
    
    def sfactor(min_temp,max_temp)
      avg = (min_temp+max_temp) / 2.0
      0.398 + 0.0171 * avg - 0.000142 * avg * avg
    end
    
    def sky_emiss(avg_v_press,min_temp,max_temp)
      avg_temp = (min_temp+max_temp) / 2.0
      if ( avg_v_press > 0.5)
        0.7 + (5.95e-4) * avg_v_press * Math.exp( 1500/(273+avg_temp) );
      else
        (1 - 0.261 * Math.exp(-0.000777 * avg * avg))
      end
    end
    
    # Here's the old Java code
    # double rad_lat =       lat *Math.PI/180.0;
    # double DailyToSol =    0.0864 * DToSol;
    # double Declin =    0.41 *Math.cos( 2 * Math.PI * ( dayOfYear -172. ) / 365. );
    # double Sunrise_Angle = Math.acos( -1*Math.tan(Declin) * Math.tan(rad_lat));
    # double Sunrise_Hour = 12 - ( 12 / Math.PI ) * Sunrise_Angle;
    # double Day_Hours = 24 - 2 * Sunrise_Hour;

    # double AvEIR = SOLCON * ( 1 + 0.035 * Math.cos( 2 * Math.PI * dayOfYear / 365. ) );
{'fraction_non_alphanumeric': 0.14049226747985188, 'fraction_numerical': 0.07275103463297757, 'mean_word_length': 1.8826114249843064, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2449024', 'n_tokens_mistral': 2143, 'n_tokens_neox': 1877, 'n_words': 371}