Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. % Julia Casagrande
  2. % BEE 1510: Intoduction to Computer Programming
  3. % Laboratory Exercise #6
  4. % Title: Rainfall Excess and Surface Runoff: Files and Arrays
  5. % Purpose: determine snow depth and snow melt
  6. % for each day of the year, based on the weather data
  7. % Laboratory TA: Maureen Murage
  8. % Graham Nekut
  9. % Last Modified: 10/13/10
  10.  
  11. % Variable Dictionary
  12. % precip_data = precipitation data file
  13. % precip_read = function to read precipitation data
  14. % A = array of precipitation data
  15. % temp_data = temperature data file
  16. % tp = function to read temperature
  17. % B = array of temperature data
  18. % C = matrix of temperature data when precipitation is rain
  19. % D = matrix of temperature data when precipitation is rain
  20. % isFrozen = days when ground is frozen
  21. % isDormant = days when ground is dormant
  22. % day = day of the year
  23. % K = snow melta parameter; .45
  24. % H2O_shed_data = water shed data file
  25. % H2Oread = function to read water shed data
  26. % E = array of water shed data
  27. % Q_ti = depth of water runoff
  28. % S_ti = potential retention of precipitation (max soil water
  29. % retention parameter)
  30. days = 1:365;
  31.  
  32. precip_data = '151PRECP.DAT';
  33. precip_read = readPrecipitation(precip_data);
  34.  
  35. temp_data = '151TEMP.DAT';
  36. tp = readTempFile(temp_data);
  37.  
  38. rain = find(tp >= 0);
  39. snow = find(tp < 0);
  40.  
  41.  
  42. rainfall = zeros(365,1);
  43. rainfall(rain) = precip_read(rain);
  44.  
  45. snowfall = zeros(365,1);
  46. snowfall(snow) = precip_read(snow);
  47.  
  48. isFrozen = false(365,1);
  49. isDormant = false(365,1);
  50.  
  51. days_frozen = 120:305;
  52. days_dormant = 121:304;
  53.  
  54. isFrozen(days_frozen) = true;
  55. isDormant(days_dormant) = true;
  56.  
  57.  
  58. isFrozen = days <= 120 | days >= 305;
  59. isDormant = days >= 121 & days <= 304;
  60.  
  61. K = 0.45;
  62. snow = 0;
  63. snow_base = zeros(365,1);
  64. snowmelt = zeros(365,1);
  65. snowmelt_actual = zeros(365,1);
  66.  
  67. for days=[1:365]
  68. snowmelt(days) = max((K*tp(days)),0);
  69. snow = snow + snowfall(days) - snowmelt(days);
  70. snow_base(days) = snow;
  71. snowmelt_actual(days) = min(snowmelt(days), snow_base(days));
  72. end
  73.  
  74. H2O_shed_data = 'H2OSHED.DAT';
  75. [land_use_area, reference_curve_num] = readH2O(H2O_shed_data);
  76. land_use_area_m = land_use_area.*((1000)^2);
  77.  
  78. am = antecedentMoisture(rainfall, snowmelt_actual);
  79.  
  80. % Calculate antecedent moisture
  81. for days = 1:365
  82. runningsum = 0;
  83. for J = (days-1):(days-5)
  84. am = rainfall(J) + snowmelt_actual(J);
  85. runningsum = runningsum + am;
  86. end
  87. end
  88.  
  89.  
  90.  
  91.  
  92. for land_type = 1:length(reference_curve_num)
  93.  
  94. cn = curveNumber(reference_curve_num(land_type), am, snowmelt_actual, isDormant, isFrozen);
  95.  
  96. S(land_type, days) = (2540/cn(days))-25.4;
  97.  
  98. for days = 1:365
  99. % Calculate daily curve numbers
  100.  
  101.  
  102.  
  103.  
  104. % Calculate depth of water runoff
  105. if precip(days)> 0.2*S(days)
  106. Q(days, land_type) = ((precip(days)- 0.2*S(days, land_type))^2)/(precip(days)- 0.8*S(days))*(land_use_area_m);
  107. else
  108. Q(days, land_type) = 0;
  109. end
  110. end
  111. end
  112.  
  113. plot(Q)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement