-
Notifications
You must be signed in to change notification settings - Fork 23
/
ReadRadarMap.c
executable file
·61 lines (50 loc) · 1.72 KB
/
ReadRadarMap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* SUMMARY: ReadRadarMap.c - Read radar precipitation map from file
* USAGE: Part of DHSVM
*
* AUTHOR: Bart Nijssen
* ORG: University of Washington, Department of Civil Engineering
* E-MAIL: [email protected]
* ORIG-DATE: Apr-96
* DESCRIPTION: Read radar precipitation map from file
* DESCRIP-END.
* FUNCTIONS: ReadRadarMap()
* COMMENTS:
* $Id: ReadRadarMap.c,v 1.4 2003/07/01 21:26:22 olivier Exp $
*/
#include <stdio.h>
#include <stdlib.h>
#include "settings.h"
#include "data.h"
#include "DHSVMerror.h"
#include "fileio.h"
#include "functions.h"
#include "constants.h"
#include "sizeofnt.h"
/*****************************************************************************
ReadRadarMap()
*****************************************************************************/
void ReadRadarMap(DATE * Current, DATE * StartRadar, int Dt, MAPSIZE * Radar,
RADARPIX ** RadarMap, char *FileName)
{
const char *Routine = "ReadRadarMap";
int i; /* counter */
int x; /* counter */
int y; /* counter */
int RadarStep; /* Location of current timestep in radarfile */
int NumberType; /* number type */
void *Array;
if (DEBUG)
printf("Reading precipitation radar data from file: %s\n", FileName);
NumberType = NC_FLOAT;
if (!(Array = (float *) calloc(Radar->NY * Radar->NX,
SizeOfNumberType(NumberType))))
ReportError((char *) Routine, 1);
RadarStep = NumberOfSteps(StartRadar, Current, Dt);
/* Read the precipitation */
Read2DMatrix(FileName, Array, NumberType, Radar->NY, Radar->NX, RadarStep);
for (y = 0, i = 0; y < Radar->NY; y++)
for (x = 0; x < Radar->NX; x++, i++)
RadarMap[y][x].Precip = ((float *) Array)[i];
free(Array);
}