Giter VIP home page Giter VIP logo

instream's Introduction

inSTREAM Version 5.0
Readme file revised 28 August 2014, SF Railsback

***inSTREAM V. 5.0 updated 28 August 2014 to fix a bug in how cells identify neighbor cells. This bug could cause significant errors (not identifying all neighbor cells, thereby restricting habitat selection by small fish) when habitat cells were laid out in the old approach of transects with rectangular cells (which was used in versions 4 and earlier of inSTREAM).***

***inSTREAM V. 5.0 updated 31 July 2014 to fix a bug in the aquatic predation survival functions, which previously eliminated the effect of piscivorous fish density on predation survival.***

Version 5.0 of inSTREAM is largely a major software update, with few changes in model formulation. The model formulation remains as described in the documentation for version 4.2 (Railsback, S. F., B. C. Harvey, S. K. Jackson, and R. H. Lamberson. 2009. InSTREAM: the individual-based stream trout research and environmental assessment model. PSW-GTR-218, USDA Forest Service, Pacific Southwest Research Station, Albany, California. Available at: http://www.fs.fed.us/psw/publications/documents/psw_gtr218/psw_gtr218.pdf). Changes in model formulation are:

1) Habitat is represented as one or more reaches of polygonal cells, instead of rectangular cells. Cells can have any number of sites. This allow fully two-dimensional representation of habitat. This is the first version that supports multiple two-dimensional reaches.

2) Barriers to upstream movement are not represented in version 5.0. This change is simply because barriers are not trivial to define with the two-dimensional habitat. 

3) The method for calculating distance from a cell to the reach's end is modified to accomodate the two-dimensional habitat representation. This method is used by fish in determining which cells in other reaches are potential movement destinations.

Software changes include:

1) inSTREAM is now packaged with a graphical user interface for Windows users. This GUI supports assembly and checking of input sets, setup of simulation experiments, and automated sensitivity ("limiting factors") analysis.

2) The MinGW compiler is used to produce a Windows executable of the model. Hence, using inSTREAM no longer requires installation of Swarm on Windows computers. Installing the model either as a stand-alone executable or within the GUI requires only copying the necessary directories and files.

3) A new approach is used by the HabitatSpace class to identify cells within a specified distance (its method getNeighborsWithin: aRange). This method uses the KD-Tree data structure instead of simply calculating the distance to each cell, and should provide faster execution. 

4) Almost all input files (except Setup files) can now be in .CSV format, facilitating their preparation in Excel or other spreadsheet and statistical software. The EcoSwarm TimeSeriesInput manager was modified to read input files with values separated either by commas or white space.

5) The EcoSwarm BreakoutReporter that writes output files was modified to (a) produce output in .CSV format, and (b) write output in a format with fewer columns that is more convenient for analysis via Excel's "PivotTables" and statistical software.

6) Optional output is now controlled via (optional) parameters in the Model.Setup file instead of by code statements. Hence, optional output can be turned on and off without re-compiling the software.

7) A new optional output reports the state of each individual fish.

8) A number of cleanups such as reorganizing the setup files to better separate observer and model parameters, and a thorough search for memory leaks.

9) Four digital documents (available as PDF and HTML Help files) provide documentation of (a) the model formulation, (b) the model software, (c) the graphical user interface, and (d) the "Limiting Factors Tool" built into the GUI. These documents are included as help files in the GUI.

Production of inSTREAM version 5.0 was funded via the project "Adaptation of inSTREAM for Steelhead" conducted by Lang, Railsback & Associates for Earth Systems Institute, with funding from the U.S. Forest Service. 

Many of the software improvements in inSTREAM 5.0 were original made for the project "Improvement of Salmon Life-Cycle Framework Model (inSALMO)", Contract R09PS20027, conducted by Lang, Railsback & Associates and USDA Forest Service Redwood Sciences Lab, Arcata CA, for U. S. Bureau of Reclamation,  Mid-Pacific Regional Office. 

inSTREAM 5.0 was developed by Steven Railsback and Bret Harvey, and software development was by Colin Sheppard, Steve Jackson, and Charles Sharpsteen.


For information and assistance contact:
	Steve Railsback
	Lang, Railsback & Assoc.
	Arcata, CA, USA 95521
	[email protected]

 or:

	Bret Harvey
	USDA Forest Service
	Redwood Sciences Laboratory
	Arcata, CA, USA 95521
	http://www.fs.fed.us/psw/rsl/

inSTREAM software and its documentation are copyright 2011 by Lang, Railsback & Associates, and distributed as free software under the GNU General Public License (see file LICENSE). 

instream's People

Contributors

colinsheppard avatar sfrailsback avatar

Stargazers

 avatar

Watchers

 avatar  avatar

instream's Issues

Refactor ReddSumperImp to ReddSuperimp

Here's a cleanup you could please do to inSALMO to keep it from driving people nuts in Windows. I globally changed "ReddSuperImp_" to "ReddSuperimp_" (small "i" instead of "I", because when one fish builds a redd on top of another redd, it is "superimposition", although nontechnically it is also a super imposition.)

But somehow there are still two files in there called ReddSuperImpXXX.h. When you un-tar the package in Windows, it overwrites the good file ReddSuperimpxxx with the old file ReddSuperImpXXX. THen it won't compile.

So if you could just find and delete the two files with capital I in their name...

Redds.out

Output file Redds.out: (a) get rid of header for “Transect Number” (transects no longer exist in this version. they were eliminated from the output lines but not the header). (b) make the output .csv format.

Will be fixed first in inSALMO. Code to open the file and write headers is in TroutModelSwarm and code to write each line is in Redd.m.

Standard Input Files

Is there a place in the repository for the standard input files? Could be a separate branch or something for each model. That would be nice.

Fix hydraulic file reader: number of flows

This was fixed in inSALMO but not instream:

So, SteveJ had cleverly hidden a limit on the number of flows you can include in the hydraulic file. Look for this line in HabitatSpace.m:

flow = (double *) [habitatZone alloc: 24*sizeof(double)];

He's allocating an array of flows with length 24.

I fixed my copy; can you fix the official version? Let's replace the 24 with a local variable declared and set at the top of the method, called something like "maxFlowsInFile" and set it to 100.

Clean up drop in HabitatSpace, PolyCell

HabitatSpace drop: It looks like we’re trying to drop a lot of stuff that is never used (cornerCoords etc.) or drop stuff twice. And in PolyCell -drop we’re trying to drop something we’re not using, which causes warning statements at end of run.

Clean out junk we do't need, etc.

(Submitted for inSALMO too)

Clean up getNeighborsWithin:

Clean up getNeighborsWithin: to fix movement among reaches. Copy from inSALMO.

HabitatSpace.hm: add methods addUpstream(downstream)CellsWithinRange: toList
Overhaul getNeighborsWithin
Fishcell.hm, TroutObserverSwarm.m: add tag method to tag neighborsWithin:
Put the cell and neighbor tagging methods from inSALMO into the habitatSpace and cell probe displays.

Clean up FishCell vs. PolyCell

Both FishCell and PolyCell have methods getPolyCellDepth. Put in FishCell. Velocity update is in FishCell but depth update is in PolyCell. Put both in FishCell. PolyCell should only have geometry and color stuff. Look for other redundancies/confusion. (FishCell is a subclass of PolyCell.)

Fixed in inSALMO -- its issue #21. Should be able to copy PolyCell (not FishCell) from inSALMO.

Test and update optional output files

See which of the optional output files listed in Sect. 24 of the inSTREAM manual need fixing-- e.g., they no longer work, or need their format updated to remove "transect number" etc.
Also submitted to inSALMO.

DO NOT round floats off; leave in scientific notation. (We need the precision for code testing.)

Fix hydraulic file reader: tabs at end of line and error checking

This may have already been fixed: HydraulicFileReader crashes if there is white space (tabs, at least) at the end of a line.

Also: the documentation says that the code makes these checks, not all of which are implemented yet:
The software makes several checks when reading in the cell hydraulics
file:
• The cell numbers must correspond with those in the cell geometry
file: each cell defined in the geometry file receives hydraulic input
and there are no cells in the hydraulic file but not in the geometry file.
• The flows on line 3 must be in order of increasing magnitude.
• The number of values on each row of hydraulic input (file lines 5 and
higher) must equal one (the cell number) plus two times the number
of flows defined line 3.
• There must be no negative velocities.
• Any negative depth values are set to zero (some hydraulic models as-
sign negative depths to locations above the water level).

(submitted for inSALMO too.)

Fix left-open file in TimeSeriesInputManager.m

TimeSeriesInputManager.m has an optional method printDataToFileNamed. This method opens an output file and forgets to close it (just found this problem in a completely different code).

I think we just need:

fclose(filePtr);

right before the return statement.

(This class is part of EcoSwarm, which I need to update as we finish up this version of instream.)

PolyCell area calc.

In PolyCell.m, delete line 634 (which multiplies cell area by 10,000). It’s wrong because we already converted polygon coordinates from meters to cm.

Add new optional output: IndividualFishReport

Add new optional output file that reports the state of each fish. It should be named "IndividualFishReport.csv"

The file reports one line per live fish, on each output date. The line reports: Scenario, Replicate, date, fish ID, reach name, cell number, species name, age, length, weight, condition.

The code to write the file lines is in a temporary version on Steve's laptop Linux at:
SwarmApps2.2.5/inSTREAM_4.2.2_AllFishOut/TroutModelSwarm.hm. (This will require slight modification because it's an old version with transects and cell numbers; now we do not have trnasect numbers. This temporary version called the file "AllFishReport", but let's use "IndividualFishReport".)
It requires:
a) Adding a unique integer ID to each fish, (done; new IVar in Trout.h; new fish counter and assignment in TroutModelSwarm.m createNewFishWith...)
b) Optional (IFDEF) statements to open and write to the file: see model swarm method printAllFishReport (and how outputting the report was added to the schedule).

Still to do: create separate file open method that writes header information to file and decides whether it should be overwritten and appended; can use openReddSummaryFilePtr as a template.

Added to software documentation 11/30/2011

Hydraulic file reader

Incorporate the checks mentioned in the inSTREAM documentation. (or suggest other ones). See Sect. 3.4 of attached documentation (in email from Steve 4/12/11).

Remove StationObject.hm

I am pretty sure we're no longer using the class StationObject ..... so remove it from code archive.

Make redd mortality output file optional

The reddMortalityFile is huge and not easy to use... Let's make it an optional file, controlled like the other optional files from TroutModelSwarm.h. I'll update the documentation. Hardwire its name to Redd_Mortality_Out.csv and remove from Model.Setup.

Check TimeSeriesInputManager, BreakoutReporter versions

Make sure we're using the same versions of TimeSeriesInputManager, and BreakoutReporter, from inSALMO.
TimeSeriesInputManager should figure out if files are in .csv format
BreakoutReporter should have two create methods, one for .csv; and produce breakout results in one instead of multiple columns.

Catch negative depths from interpolator

PolyCell.m updatePolyCellDepthWith: Negative depths from interpolator – Can happen at flow < lowest flow in interpolator. Fix so they are set to zero.

(This was already done in inSALMO)

Cell data file and hydraulic files use .csv

Make it allowable for the cell data file and the hydraulic data file (not cell geometry file) to be in .csv format

These files are identical to those in inSALMO, so can copy insalmo code for reading them.

Parameter update- fishEMForUnknownCells

The fish parameter fishEMForUnknownCells is used only for barriers, which we removed from this version. So remove the param from Trout.h and the trout parameters input file.

Implement faster depth and velocity updates?

FishCell has unused method calcDepthAndVelocityWithIndex. Why don’t we use it? (To understand this, see documentation for EcoSwarm InterpolationTable)

Done in inSALMO -- see #20. Seemed to speed it up quite a bit.

Add prev. location, fish ID to MoveReport

Modify the optional move report as done for insalmo:
a) Give each fish a unique integer ID, in [troutmodelswarm createNewFishWith...]
b) Fish update variables for prevCell, prevReach whenever they move (look for places where moveToBestDest is called)
c) MoveReport includes fish ID, current and previous cell and reaches.

Change FishID in optional output files

Some optional output files (e.g., spawn_cell) include a FishID variable. Currently these are the fish's address, created by printing "self" with format "%p". I found out that these addresses are not unique: when one fish dies, another often gets its address. Instead, use the integer fishID number implemented to address issue 22. Remember to change the format from %p to %d.

Get rid of "Number of species" in Model.Setup

I don't think we really need the model setup parameter for number of species. Instead, can we set it from the Species.Setup file? It could be that we're already doing that. Let me know if it turns out not to be so simple.

Clean up Observer.Setup

Observer.Setup: raster zoom factor and rasterResolution seem to do nothing and need to be cleaned out.

We want to get rid of rasterResolution because it is never used for anything. rasterResolution is used to set a variable polyRasterSize but that variable is never used. rasterResolution is also passed from TroutObserverSwarm to TroutModelSwarm (in two places) and frmo there to HabitatManager to HabitatSpace to PolyCell. But none of these seem to use it.

Raster zoom factor: So, our display rasters are Swarm class ZoomRaster, which supposedly lets you zoom in and out but we never implemented the code (which would be pretty complicated, apparently) to draw stuff correctly. I think the best thing would be to change its class to Raster and get rid of ZoomFactor. DONE in INSALMO- no problem.

Prune screen output

You could also trim out some of the print statements that aren't really necessary any more. It's nice to see the major steps as the model gets built, and a few lines at the end of a run to know whether the experiment is all done, but other stuff we could get rid of.

Design Faster method for getNeighborsWithin:

1.Faster method for identifying neighbor cells within some radius, for habitatSpace getNeighborsWithin:

Perhaps: each cell has sorted list of cells by distance from self. Use Swarm arrays: one for cells, one for distance to. Use “OFfsets”: file:///C:/Swarm/Documents/Swarmdocs-2.2-objc-set/swarm.collections.offsets.protocol.html

Low priority

Fix probe maps

In TroutObserverSwarm.m, need to clean up the probe maps. They contain some variables that don't exist any more. One is:

probeMap = [CustomProbeMap create: aZone forClass: [TroutRedd class]
withIdentifiers: "Species",
"numberOfEggs",
"emergeDays",
"fracDeveloped",
"spawnerLength",
"transect",
"cellNo",
":",
We don't have transects now, and "cellNo" should be "cellNumber".

Even after fixing that, i still get warnings about null probes when run in graphics mode, so there's more wrong. (I can do this if you want.)

Check and update default inputs

I need to produce a standard input set...
Update all the setup files, especially headers

I emailed these to Colin ~Dec 5 for him to commit

Get rid of populationInitializationDate in Model.Setup

We're no longer using the model variable populationInitializationDate so delete from code and Model.Setup. (I'm pretty sure we don't use it.)

///////////////////////
Errrr, actually this true only for salmon model, not inSTREAM. The pop init date is still how we determine which input in the initial population file to use for a particular model run.

I re-opened this just to make sure the change was not made. Steve

Revise method of selecting optional output files?

It wouldn't be too much work to update the way that they optional output files are specified so we don't have to require the user to recompile in order to opt for them.

For example, there could be additional parameters in Observer.Setup which control each of the optional files.

Remove Barrier code

The code for barriers will not work in this version. We need to:
a) If barriers appear in Reach.Setup per sect. 20.2.3 of inSTREAM documentation, then raise an error that says barriers don't work in this version.
b) Remove Barrier.hm from code directory and Makefile

Restore writeFrame method in ObserverSwarm

ObserverSwarm –writeFrame: un-comment the block “if([habitatRasterList getCount] > 0)”. Uncomment “id raster = nil;”.
ObserverSwarm –buildObjects: after this statement:
[habitatRasterMap at: habitatSpace insert: polyWorldRaster];
add this one: [habitatRasterList addLast: polyWorldRaster];

Submitted also for inSALMO - same method should work for both models.

Check float format in output files

in inSALMO we made some format changes in output files--floats are not always in scientific notation.

a) Are these changes made in standard output files for inSTREAM ? If not, talk to Steve. They seem less important with the new breakout reporter format.
b) but not in the optional output files, where we are likely to need full precision for code testing.

Update raster display of cells, fish, redds

When inSALMO is stable, copy its drawSelf methods etc. so fish and cells and redds are drawn the same way. Implement the same shading code as inSALMO.

Colin: did we decide that fish are drawn as pixels while they are age 0, and rectangles when age > 0? That's what I'm putting in the documentation.

Check for Experiment manager "NONE" bug

Check ExperSwarm.m and ExperBatchSwarm.m for bug that was in inSALMO, commit cdf9526d3d Simple logic error in check whether InstanceName = None or none. SHould be "==" instead of "!=".

Cells do not know habShelterSpeedFrac

The method FishCell setHabShelterSpeedFrac is not called, so the cell variable habShelterSpeedFrac is never updated from its initial value of zero. Best solution seems to be to get rid of this cell variable and have FishCell just get this reach variable from its space.

See insalmo issue 45

LFT outputs

Add output files for the limiting factors tool. Per documentation on trout LFT done 11/23/11, replace the salmon output with the following method:
To make results easy to interpret, the LFT analyzes only two outputs from inSTREAM: abundance and biomass of adult trout. The specific measures of abundance and biomass are set by two LFT parameters. The parameter resultsAgeThreshold defines the age (years, with age 1 attained on the individual’s first January 1) of simulated trout included in the LFT results: trout with age equal or exceeding resultsAgeThreshold are included in results. The value of resultsAgeThreshold can be set to reflect the age at which trout at a study site typically spawn or (if angling is an important objective) become catchable.
The second parameter defining results is resultsCensusDay (day of year, in mm/dd format): LFT results are “censused” from the model on this day of each simulated year, and then averaged over the model run.
As an example, if resultsAgeThreshold is set to 1 and resultsCensusDay is set to 10/01, then the LFT will measure the number and total biomass (g) of all age 1 and older trout on each October 1st in the simulations. The results analyzed for each scenario will be the mean, over all simulated years, of these October 1 values.

Get rid of annoying graphs

Comment out those damn depth- and velocity-use histograms that have been annoying me for decades. (I will do this.- Steve)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.