Changeset 2680 for simo


Ignore:
Timestamp:
01/10/12 04:02:00 (4 months ago)
Author:
antti
Message:

fix to aggregation output bug #449

Location:
simo/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • simo/trunk/simulator/xml/model_chains/tree_simulator/Chain_update_basic_attributes.xml

    r2652 r2680  
    487487                                </model> 
    488488                        </task> 
    489  
    490489                        <task name="Calculate for non-seedling stand"> 
    491490                                <condition>comp_unit:pure_seedling eq 0</condition> 
  • simo/trunk/src/simo/output/aggr.py

    r2478 r2680  
    441441                                               constraints=constraints) 
    442442                data2 = set([d for d in data2]) 
     443                # sort data2 by date and reverse it 
     444                data2 = sorted(data2, key=lambda row: row[1]) 
     445                data2.reverse()                 
    443446                for range in date_ranges: 
    444447                    for row in data: 
     
    449452                                continue 
    450453                            if row[0] == row2[0]: 
     454                                # in case single range contains records at 
     455                                # multiple dates, we should take the key 
     456                                # values from the last record (which should be 
     457                                # the first item in reversed data2) 
     458                                if len(row[3:]) >= len(keys): 
     459                                    continue 
    451460                                row += row2[2:] 
    452461            data = [d[1:] for d in data] 
  • simo/trunk/src/simo/simulation/caller/predictionmemory.py

    r2594 r2680  
    132132            orig_timesteps = self._time_steps[tind[:,0],tind[:,1],tind[:,2],ind] 
    133133            no_block = timesteps != orig_timesteps 
    134  
    135134            block = enddate >= cdates 
    136135            if numpy.any(timesteps < 0): 
     
    172171        # time span unit are the same, and if not, modify the time divider 
    173172        # and time steps accordingly 
    174         timesteps, timedivider = self._match_spans(sim, timeunit, 
    175                                                    sim.timespan.unit, 
    176                                                 timespan, timesteps) 
     173        timesteps, timedivider = self._match_spans(sim, timeunit,\ 
     174                                    sim.timespan.unit, timespan, timesteps) 
    177175        if timedivider is None: 
    178176            return False 
  • simo/trunk/src/simo/simulation/sim.py

    r2673 r2680  
    1919import numpy 
    2020import time 
     21import math 
    2122from datetime import date 
    2223from collections import defaultdict 
     
    675676                if self.terminate: 
    676677                    break 
    677  
     678                 
    678679                # update chain index 
    679680                self.chain_index += 1 
     
    10891090                    year_as_units = 1. 
    10901091                elif unit == names.MONTH: 
    1091                     units = ((end - start).days - 1.) / 30. 
     1092                    units = ((end - start).days - 1.) / 31. 
    10921093                    year_as_units = 12. 
    1093                 steps = int(units / self.timespan.time_step) + 1 
     1094                steps = math.ceil(units / self.timespan.time_step) 
    10941095                timesteps[:] = year_as_units / steps 
    10951096 
Note: See TracChangeset for help on using the changeset viewer.