Friday, February 25, 2011

ArcGIS tip-- joins and relates

Joins and relates are a way for you to add data to an already existing feature class file. For example, you might have a polygon that you want to assign the value of 100 to... or you might have points that represent the location of birds, and you want to give the number of birds.

How to do this?
First you are going to want to put the information you want to assign into an Excel file as a column vector.
Next to that vector, you want to replicate at least one vector from your pre-existing Feature class file:

See the column I wanted to add (above) is "prod" and one line of information from my feature class (already on the map) is "OBJECTID_1".  It's crucial you title this column EXACTLY THE SAME as the column in your data. It makes it easier. Sometimes it will work if different, but this helps me stay organized.

Now in Arc, right click on your feature and you'll get a pop up window for "joins and relates"

You can either use a join or a relate. Joins are more permenant; relates sometimes go away. But joins are more taxing on the computer and relates are not. So my advise is-- use relates to figure out what you want, and then join.

So in the first blank (not the drop down, but the number 1) you will choose your pre-existing feature class on your map.  In the second one, navigate to your excel file.
REMEMBER 2 things: Arc hates finding things that it is not "connected to"- connect to that drive, at least, using ArcCatalog. Arc likes Excel files more than CSV's or TXT. Titles make Arc happy! So .xlsx WITH TITLES is the way to go.

In the third blank, choose the OBJECT ID or other column that you named the same as the column in the map. OK will light up.

Now wait and pray.


OKAY! There's your data, imported, maybe labeled if you want. That's the end!

Saturday, February 19, 2011

Model Results kinda

Well, so I made some major tweaks to the model. The boss had some good ideas that I implemented, and as it turns out, she was mostly right.

I omitted a good bit of tree competition stuff and focused more on using the slope gradient to drive the biomass. Actually it came out nicely.
I realized a big flaw with the model is that I have no way of deleting dead trees once they have turned back into soil. I may leave this flaw in the model because I think it is curious; it may be able to be used in some way to back out atmospheric deposition (since carbon is entering the system with each time step). Maybe not. I'm not sure. But it would be cool to think about it, and at least I can ask the prof or show that I noticed this myself!

Here's a nice picture from some of the results

I know you are probably thinking--- your fits suck! But actually, KS test says otherwise. Oh, statistical slam my friends! Now it isn't a GREAT fit, but it is a fit. 0.08.... barely above that I don't fit line. Imagine what would happen if I got rid of that tail. I should work on that...but not now. Too many things to do.
Tomorrow I must go to HJ. Should be fun. Tonight I must go relax, print articles, maybe walk, rent a film, etc. oh no. :)

Friday, February 18, 2011

As I promised

Well,so I've heard bad things about this status change but
Today my manuscript went from Awaiting AE Decision to Awaiting EIC Decision

I guess it would need to await that decision either way.

But let's recap the time frame.

It's now Feb 18th.
The manuscript was submitted on Dec 27.
This was the second submission following an initial round of reviews that took approximately 4 months.
We originally submitted sometime last August.

Please keep these timelines in your head if you are submitting; this is probably a good WCS for temporal scale.

Tuesday, February 15, 2011

my silly penman-monteith code

Warning! NONE OF THESE PARAMETERS ARE EVEN CLOSE TO REALISTIC! YOU NEED TO GO FIND THEM!

I need to learn Penman-Monteith if I want to be a wind person.
About what I knew prior to this silly exercise was "it calculates net ET!" how? where? to what extent?
There was only one solution... write a MatLab code to try it out. So, without understanding exactly what half of the parameters meant, I made a little PM toy. I want to put it here not because it's a great example of code, but maybe because I missed something, or maybe because someone else might want to not type all of PM into a code.
Source of the PM equation I used was the FAO website (http://www.fao.org/docrep/x0490e/x0490e06.htm#penman monteith equation

I used their examples,too:

%------------------------------------------BEGIN!

%penman.m

% calculates net ET using PM equation

%parameters and surrogate functions

%----------------grass set--------------------
%d = 2/3;                          % zero plane displacement height
%zm = 2;                           % height of wind measurements in m
%zom = 0.123;                      % roughness length govern momentum transfer
%zh = 2;                           % height of humidity measures
%zoh = 0.1*zom;                    % roughness length hv if not given
%uz = 1;                           % wind speed at height
%h =0.12;                          % crop height
%k = 0.41;
%rl= 70;                           % single grass leaf stomatal resistance

% note that the FAO grass reference has h = 0.12, rl=70,and albedo =0.23.
%-----------------------------------------

%----------------- test set---------------------------

Rn = 2000;                        % net radiation (MJ/M2/d)
G = 500;                          % soil heat flux (MJ/M2/day)
rhoA = 2;                         % mean air density
cP = 4;                           % specific heat air
es = 10;
ea = 7;                           % es-ea vpd of air
%ra = 5;                          % aerdyn resistance
d = 2/3;                          % zero plane displacement height
zm = 2;                           % height of wind measurements in m
zom = 0.123;                      % roughness length govern momentum transfer
zh = 2;                           % height of humidity measures
%zoh = 3;                         % roughness length governing trans of heat/vap
zoh = 0.1*zom;                    % roughness length hv if not given
k = 0.41;                         % vonkarmans constant
uz = 1;                           % wind speed at height
h =0.12;                          % crop height

ra = (log((zm-d)*h/zom*h)*log((zh-d)*h/zoh*h))/k^2*uz;

gradient = 2;                       % slope of the saturation vp/t relate
gamma = 7;                          % psychrometric constant

% note: the bulk surface resistance describes the resistence of the vapour
% flow through the transpiring crop and soil evaporation. when veg does not
% cover the soil completely, the resistence factor should include the
% effects of evap from the soil surface.if the crop is not transpiring at
% its potential rate then teh resistence depends on the water status of the
% veg. we can do an approximation

%rs = 2;                             % bulk surface resistance, if applied in full
rl= 100;                             % bulk stomatal resist of illuminated leaf
%LAIa = 3;                            % active (lit) LAI

%----------------------LAI curve---------------------------------
t = 1:180;                      % length growing season for crop (age for tree)
LAImax = 7;                     % max feasible LAI
r = 0.05;                       % dampening coefficient for LAI curve
Lai(t) = LAImax./(1+exp(-r*t)); % generate LAI curve

% plot Lai if you want.
% plot(t, Lai(:));
% xlabel('time')
% ylabel('LAI');
% title ('Leaf Area Index with respect to time')

z = 100;                        % use z to specify your LAI from curve
LAIa = 0.5*(Lai(z));

% alternate route for grasses
% LAIa =12*h;
% rs approximation
rs = rl/LAIa;

%-------------------------end test set--------------------------
%penman equation for lambdaET
lambdaET= (gradient*(Rn-G)+rhoA*cP*(es-ea)/ra)/(gradient+gamma*(rs/ra));

% ------------------further useful substitutions--------------
% from the grass example I am working this from
% ra = 208/u;                     % aerdyn resistance
% rs = 70;                        % bulk surface resistance
% u = rs/(0.34*ra);

R = 0.287;                        % specific gas constant Kj/kg/K
% Tkelv = 1.01(T+273);            % temp in kelv
% rhoA = P/(Tkelv*R);             % mean air density
epsi =0.622;                      % molecular weight of watervap
P = 1000;                         % atmospheric pressure

lambda = 2.45;                    % latent heat of vaporization
cp = (gamma*epsi*lambda)/P;

% we can approximate Cp this way
%---------------------penman ET0------------------------------
delta = 5;                          % slope vapor press curve kPa/C
Rn = 1000;                          % net rads at surve MJ/m2/d

% note that if mean is used daily estimate of ET will be underest.
T = 5;                              % mean daily temp at 2m h


u = 0.5;                            % wind speed at 2 m height

ET0= (0.408*delta*(Rn-G)+gamma*(900/T+273)*u*(es-ea))/(delta+gamma*(1+0.34*u));



%---------------------------------------------END!!!!


I hope this is helpful for someone. FEEL FREE TO TELL ME IF I MISSED SOMETHING IN THE EQUATION. Ultimately, MatLab "toys" like to grow into bigger things, I feel like, so lest I mess up... come help!

In case you want to know more about PM ET function:
Wiki
UF Extension-- go extension!
UCD more complicated

colored glasses!

Okay, this may not look particularly impressive to you, but I think it's a really fun little tool in ArcGIS that can be used to put "colored glasses" on an area of interest. Here's how it's done.
1. import your map 
2. make sure you have enabled your spatial analyst tool, or get someone to help you enable it, or borrow someone else's ArcSuite (!)
3. Under Spatial Analyst in the toolbox, select Extraction Tools, then "Extract by Rectangle"
4. On your map, move your cursor over the top, right, left, and bottom bounds you want. You should maybe write these on paper. I.E. make a list like:
   - Top: 485961
   - Bottom: 47981
  - Left: 559987
  - Right: 560843

Then select the raster you will want to make your box from. Run the tool. It will take a bit if your computer is slow like mine.
4. Okay, now for your new rectangle, choose a color palette of R -->B, with "Invert" checked
5. Turn your original raster *pull it in if you have to and slide it to the bottom* to black and white
6. You can export it and make a legend in powerpoint if you want, like I did. I don't like the ArcLegends much because no one knows what "RasterT_Extrac1_slopeLess50" is.

Monday, February 14, 2011

maybe i should get moving on that python

Arc takes too long to run.
Whitebox needs improved operability.
TauDEM just doesn't like my computers.

So maybe I should learn Python.

Found a lovely tutorial to get my on my feet: One Day of IDLE Toying

This is a really nice one, since it actually takes time to explain things that -gasp- non-programmers! need to know, like "where do the >>> from the command prompt go in a script?" I mean, now I know that, and this was slightly below my level (WOW!) but major applause to someone for doing a beginner tutorial right.

No surprise, it's out of Berkeley. Many good things come out of Berkeley. It is my goal to work there, so I guess I hope some day I go INTO Berkeley!

Sunday, February 13, 2011

Wow, in case anyone was curious


I'm working up a budget proposal for something right now and I'd really like this software, ENVI. But wow, it's expensive!