#!MC 700 ################################################### # area.mcr 04/28/98 dms # # # # This macro will calculate the total area of all # # cells within an IJ ordered zone which lie above # # a specified contour variable limit. For # # example, you could use this variable to find # # area of all cells which have their contour # # level at or above a specified value # # The "Area" value will be stored as a variable # # in your datafile. # # # # LIMITATIONS: # # 1. This macro only works on IJ-ordered data. # # 2. Assumes that all of your cells are # # rectangular, and that I is parallel with X # # and J is parallel with Y. # # (You can modify this macro quite easily # # to enable you to calculate non-rectangular # # cells' areas or to work with data that does # # not have IJ parallel to XY.) # # 3. Runs VERY slowly. Do not click on your # # plot after starting the macro. # # A message dialog will appear when the # # calculation is complete. # #Last modified - 2/28/2006 by CLI ################################################### $!PROMPTFORTEXTSTRING |CLEVEL| INSTRUCTIONS = "Please enter the contour level that defines the area above which to intergrate:" $!DRAWGRAPHICS NO ## ##Width of Cell ## ## Height of Cell ## ##Equals zero when C<|CONTOURLEVEL|## $!ALTERDATA EQUATION "{CELLAREA} = (X(i+1,j)-X(i,j)) * (Y(i,j+1)-Y(i,j)) * MAX(SIGN(C(i,j)-|CLEVEL|),0)" #CONSTANT CELL AREA: #If the area of all of the cells in your zone is constant, #comment out the above $!ALTERDATA EQUATION command, and #un-comment this one: #$!ALTERDATA # EQUATION "{CELLAREA} = |CELLAREA| * MAX(SIGN(C(i,j)-|CLEVEL|),0)" ##This routine sums up all of the cells' areas. $!ALTERDATA EQUATION "{TOTALAREA} = 0" $!LOOP |MAXJ| $!VARSET |J| = |LOOP| $!LOOP |MAXI| $!VARSET |I| = |LOOP| $!ALTERDATA EQUATION "{TOTALAREA} = {TOTALAREA} + {CELLAREA}(|I|,|J|)" $!ENDLOOP $!ENDLOOP ##End macro and show results. $!GLOBALSCATTER VAR = |NUMVARS| $!DRAWGRAPHICS YES $!PAUSE "Area within specified contour level = |MAXS|"