Blog from June, 2009

Lunchlecture Delta in a nutShell
Goal for sprint 6
  • NetworkCoverage as 1D flow model input / output
  • NetworkCoverage in NetCDF
  • Save / Open / SaveAs Project (also NetCDF should be moved / copied)
  • JIRA Issues (check last added issues)
  • Fixed tests
Retrospectives (sprint 5)

positief:

  • QA is belangrijk
  • betrokkenheid van het team
  • HABITAT werkt
  • het doel is belangrijk (workshop)
  • betrokkenheid van Femke
  • tutorials voor de workshop
  • flow model werkt! (in principe (smile))

negatief:

  • HABITAT werkt nog niet met f(t) grids, en NetCDF nog niet stabiel is
  • de workshop verstoort het process
  • te optimistische schatting van de sprint
  • aantal componenten van het systeem zijn nog te instabiel (refactoring (smile))
  • opslag niet goed werkt
  • "wat moet ik nu doen?"
  • sprint stories beter uitwerken
  • backlog is not niet beschikbaar
Presentation for internal workshop
TestHelperFunctions.GetCurrentMethodName()

I added functionality for auto-generating path names based on current class and method. This is handy in test classes where the name of the saved data should resemble the test name.

[TestFixture]
public class NHibernateNetworkTest
{
     [Test]
     [Category("DataAccess")|Category("DataAccess")]
     public void SaveFullNetworkSchematizationWithMap()
     {
        string path = TestHelperFunctions.GetCurrentMethodName() + ".dsproj";
        //path == NHibernateNetworkTest.SaveFullNetworkSchematizationWithMap.dsproj
     }
}

This makes it easier to move tests around and keep the name consistent

Enumerable.Range, Enumerable.Repeat

Enumerable.Range can be used to create a sequence of numbers. By default it can create an IEnumerable<int> in the following way:

Enumerable.Range(0, 5) generates the following sequence: 0,1,2,3,4

Combining this functionality with a lambda expression you can generate any type of numbered list

doubles
Enumerable.Range(0,5).Select(n=>(double)n) generates the sequence 0.0,1.0,2.0,3.0,4.0

or an expression (function)
offset = 4.0
step =0.2
Enumerable.Range(0,5).Select(n=>offset n*step) yields 4.0, 4.2, 4.4, 4.6, 4.8

Enumerable.Repeat can be used to create a sequence of numbers that are all the same
Enumerable.Repeat(5, 3) yields 5, 5, 5

I guess when you first look at this code it can be quite puzzling and you might prefer to use the more common approach for readability. Please let me know what you think.

double [] mySequence = new double[5];
double offset = 4;
double step =0.2
for (int i=0;i<5;i++)
{
   mySequence[i]= offset + i * step;
}

see also http://visualstudiomagazine.com/articles/2009/04/01/make-your-code-clear.aspx http://stevenharman.net/blog/archive/2008/02/12/ruby-has-ranges-and-so-does-c.aspx

Image debugger visualizer
Scrum session planning

The next scrum session will have to produce a version of Delft Shell that can be used in the upcoming user conference june 25th. Therefore known bugs in the user interface, model run and data storage should be fixed. The following stories where planned

Must have

Run flow model

-Sobek sim should not crash for relevant test cases (Jan Noort should be contacted asap to help to fix model)

Initial conditions editor

-user should be able to set initial conditions globally

Boundary conditions editor

Gis

-make gis functionality stable, resolve bugs
-fix theme editor
-check profile tool
-show animation of existing sobek 2d output

Results map

-model results should be in separate networkcoverage
-these coverage should be shown on the map with specific symbology
-it must be possible to show labels on the map for the results

Network editor

-network editor should work for exercises during workshop increase stability

Save and load project

-check mappings, write unit test to check serialization/deserialization of map data.
-improve performance for importing from lit directory of existing sobek
-import initial and boundary conditions from existing sobek

Should have

Results table

Results chart

-click on a point on the map, show time dependent data in a chart for the nearest calculation point.

Won't have

Initial conditions coverage

-editor
-visualization of
-interpolated values along branch (at every calculation point)
functionality to interpolate is in parsen executable (fortran)

Initial conditions editor

-select path along the network, set initial conditions using editor (multi data editor)

SideView

Scripts slowing down firefox

I have installed a plugin in firefox that prevents sites from running scripts on your pc https://addons.mozilla.org/en-US/firefox/addon/722
After that you just enable to run scripts from sites you know. Teamcity pages appear a lot faster now (smile)

When to call GC.Collect

Ideally you should not have to call the Garbage Collector in .net code and this exactly what many online resources claim. .Net garbage collector works with generations. When an object is allocated it is of generation 0 and the more (garbage) collects it survives the higher the generation (currently only generations 0, 1 and 2 exist) becomes. During a collect objects of the relevant generation are checked and released if unreferenced.
Thus calling an unnecessary GC.Collect will increase the generation and even prevent the fast release of objects.

The CLR will call GC.Collect(0) frequently and GC.Collect(2) rarely.

When working with map themes and large grid coverages in DelftShell we noticed an unnecessary long survival for unused objects. Apparently this is caused by the following scenario:
-allocate large object
-perform time consuming algorithm (generation of object will increase)
-dereference object

the default GC.Collect(0) will fail because large object is of generation 1 or even 2.
In this case it is useful to call GC.Collect() (=GC.Collect(2))

References:

Rico Mariani's Performance Tidbits

When to call GC.Collect() http://blogs.msdn.com/ricom/archive/2004/11/29/271829.aspx

Two things to avoid for better memory usage http://blogs.msdn.com/ricom/archive/2003/12/02/40780.aspx

Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework http://msdn.microsoft.com/en-us/magazine/bb985010.aspx

Garbage Collection Part 2: Automatic Memory Management in the Microsoft .NET Framework http://msdn.microsoft.com/en-us/magazine/bb985011.aspx

  1. Downloag and install FWTools, use FWTools 2.3.0 (Windows 32bit) link.
  2. Install HDF Explorer
  3. Register HDF Explorer as a viewer for *.nc files (in Windows Explorer Open with ..., then Browse to HDF Explore and check *Always use this program to open ...).
  4. Convert any source raster file into NetCDF using GDAL:
    gdal_translate.exe -of netCDF input_file.asc output_file.nc
    
  5. Click on output_file.nc to view it using HDF Explorer.