private int [ ] [ ] createStationBasinsMatrix ( double [ ] statValues , int [ ] activeStationsPerBasin ) { int [ ] [ ] stationsBasins = new int [ stationCoordinates . size ( ) ] [ basinBaricenterCoordinates . size ( ) ] ; Set < Integer > bandsIdSet = bin2StationsListMap . keySet ( ) ; Integer [ ] bandsIdArray = ( Integer [ ] ) bandsIdSet . toArray ( new Integer [ bandsIdSet . size ( ) ] ) ; // for every basin for ( int i = 0 ; i < basinBaricenterCoordinates . size ( ) ; i ++ ) { Coordinate basinBaricenterCoordinate = basinBaricenterCoordinates . get ( i ) ; // for every stations band int activeStationsForThisBasin = 0 ; for ( int j = 0 ; j < bandsIdArray . length ; j ++ ) { int bandId = bandsIdArray [ j ] ; List < Integer > stationIdsForBand = bin2StationsListMap . get ( bandId ) ; /* * search for the nearest stations that have values. */ List < Integer > stationsToUse = extractStationsToUse ( basinBaricenterCoordinate , stationIdsForBand , stationId2CoordinateMap , statValues , stationid2StationindexMap ) ; if ( stationsToUse . size ( ) < pNum ) { pm . message ( "Found only " + stationsToUse . size ( ) + " for basin " + basinindex2basinidMap . get ( i ) + " and bandid " + bandId + "." ) ; } /* * now we have the list of stations to use. With this list we * need to enable (1) the proper matrix positions inside the * stations-basins matrix. */ // i is the column (basin) index // the station id index can be taken from the idStationIndexMap // System.out.print("STATIONS for basin " + basinindex2basinidMap.get(i) + ": "); for ( Integer stationIdToEnable : stationsToUse ) { int stIndex = stationid2StationindexMap . get ( stationIdToEnable ) ; stationsBasins [ stIndex ] [ i ] = 1 ; // System.out.print(stationIdToEnable + ", "); } // System.out.println(); activeStationsForThisBasin = activeStationsForThisBasin + stationsToUse . size ( ) ; } activeStationsPerBasin [ i ] = activeStationsForThisBasin ; } return stationsBasins ; }
Creates the stations per basins matrix .