src/main/java/org/opensha/sha/earthquake/rupForecastImpl/WGCEP_UCERF_2_Final/griddedSeis/NSHMP_GridSourceGenerator.java
public double[] readGridFile(String fileName, boolean addToSumOfAllAvals) {
		double[] allGridVals = new double[numAvals];
//		System.out.println("    Working on "+fileName);
		try { 
			InputStreamReader ratesFileReader = new InputStreamReader(getClass().getResourceAsStream(fileName));
			BufferedReader ratesFileBufferedReader = new BufferedReader(ratesFileReader);
			String ratesLine = ratesFileBufferedReader.readLine(); // skip header
			ratesLine = ratesFileBufferedReader.readLine();
			int index = 0;

			while(ratesLine!=null) { // iterate over all locations
				allGridVals[index] = Double.parseDouble(ratesLine);
				index += 1;
				ratesLine = ratesFileBufferedReader.readLine();
			}
			ratesFileBufferedReader.close();
			ratesFileReader.close();
		}catch(Exception e) {
			e.printStackTrace();
		}

		//now keep only the ones in the RELM region
		double[] gridVals = new double[region.getNodeCount()];
		for(int i=0;i<gridVals.length;i++) {
			int aValIndex = aValIndexForLocIndex[i];
			if(aValIndex != -1) {  // ignore the RELM locs outside the NSHMP region
				gridVals[i] = allGridVals[aValIndex];
				if(addToSumOfAllAvals) sumOfAllAvals[i]+=gridVals[i];
			}
			else
				throw new RuntimeException("Problem with indices!");
		}
		return gridVals;
	}
/**
	 * this reads an NSHMP grid file.  The boolean specifies whether to add this to a running 
	 * total (sumOfAllAvals[i]).
	 * This could be modified to read binary files
	 * @param fileName
	 * @return
	 */
this reads an NSHMP grid file.  The boolean specifies whether to add this to a running
total (sumOfAllAvals[i]).
This could be modified to read binary files
@param fileName
@return
this reads an NSHMP grid file . The boolean specifies whether to add this to a running total ( sumOfAllAvals [ i ] ) . This could be modified to read binary files @param fileName @return
public double[] readGridFile(String fileName, boolean addToSumOfAllAvals) {
		double[] allGridVals = new double[numAvals];
		try { 
			InputStreamReader ratesFileReader = new InputStreamReader(getClass().getResourceAsStream(fileName));
			BufferedReader ratesFileBufferedReader = new BufferedReader(ratesFileReader);
			String ratesLine = ratesFileBufferedReader.readLine(); 
			ratesLine = ratesFileBufferedReader.readLine();
			int index = 0;
			while(ratesLine!=null) { 
				allGridVals[index] = Double.parseDouble(ratesLine);
				index += 1;
				ratesLine = ratesFileBufferedReader.readLine();
			}
			ratesFileBufferedReader.close();
			ratesFileReader.close();
		}catch(Exception e) {
			e.printStackTrace();
		}
		double[] gridVals = new double[region.getNodeCount()];
		for(int i=0;i<gridVals.length;i++) {
			int aValIndex = aValIndexForLocIndex[i];
			if(aValIndex != -1) {  
				gridVals[i] = allGridVals[aValIndex];
				if(addToSumOfAllAvals) sumOfAllAvals[i]+=gridVals[i];
			}
			else
				throw new RuntimeException("Problem with indices!");
		}
		return gridVals;
	}
public double [ ] readGridFile ( String fileName , boolean addToSumOfAllAvals ) { double [ ] allGridVals = new double [ numAvals ] ; try { InputStreamReader ratesFileReader = new InputStreamReader ( getClass ( ) . getResourceAsStream ( fileName ) ) ; BufferedReader ratesFileBufferedReader = new BufferedReader ( ratesFileReader ) ; String ratesLine = ratesFileBufferedReader . readLine ( ) ; ratesLine = ratesFileBufferedReader . readLine ( ) ; int index = 0 ; while ( ratesLine != null ) { allGridVals [ index ] = Double . parseDouble ( ratesLine ) ; index += 1 ; ratesLine = ratesFileBufferedReader . readLine ( ) ; } ratesFileBufferedReader . close ( ) ; ratesFileReader . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } double [ ] gridVals = new double [ region . getNodeCount ( ) ] ; for ( int i = 0 ; i < gridVals . length ; i ++ ) { int aValIndex = aValIndexForLocIndex [ i ] ; if ( aValIndex != - 1 ) { gridVals [ i ] = allGridVals [ aValIndex ] ; if ( addToSumOfAllAvals ) sumOfAllAvals [ i ] += gridVals [ i ] ; } else throw new RuntimeException ( "Problem with indices!" ) ; } return gridVals ; }
this reads an NSHMP grid file.
this reads an NSHMP grid file .
//		System.out.println("    Working on "+fileName); // skip header // iterate over all locations //now keep only the ones in the RELM region // ignore the RELM locs outside the NSHMP region