コード例 #1
0
 /*WorldPoint3D CATSMover3D_c::GetMove(const Seconds& start_time, const Seconds& stop_time, const Seconds& model_time, Seconds timeStep,long setIndex,long leIndex,LERec *theLE,LETYPE leType)
 {
 Boolean useEddyUncertainty = false;	
 double 		dLong, dLat;
 WorldPoint3D	deltaPoint={0,0,0.};
 WorldPoint refPoint = (*theLE).p;	
 VelocityRec scaledPatVelocity = this->GetScaledPatValue(refPoint,&useEddyUncertainty);
 if(leType == UNCERTAINTY_LE)
 {
 AddUncertainty(setIndex,leIndex,&scaledPatVelocity,timeStep,useEddyUncertainty);
 }
 dLong = ((scaledPatVelocity.u / METERSPERDEGREELAT) * timeStep) / LongToLatRatio3 (refPoint.pLat);
 dLat  =  (scaledPatVelocity.v / METERSPERDEGREELAT) * timeStep;
 
 deltaPoint.p.pLong = dLong * 1000000;
 deltaPoint.p.pLat  = dLat  * 1000000;
 
 return deltaPoint;
 }
 
 VelocityRec CATSMover3D_c::GetScaledPatValue(const Seconds& model_time, WorldPoint p,Boolean * useEddyUncertainty)
 {
 /// 5/12/99 JLM, we only add the eddy uncertainty when the vectors are big enough when the timeValue is 1 
 // This is in response to the Prince William sound problem where 5 patterns are being added together
 VelocityRec	patVelocity, timeValue = {1, 1};
 TOSSMTimeValue*  scalingTimeDep = nil;
 float lengthSquaredBeforeTimeFactor;
 
 if(!this -> fOptimize.isOptimizedForStep && this->scaleType == SCALE_OTHERGRID) 
 {	// we need to update refScale
 this -> ComputeVelocityScale(model_time);
 }
 
 // get and apply our time file scale factor
 if (timeDep && bTimeFileActive)
 {
 // VelocityRec errVelocity={1,1};
 // JLM 11/22/99, if there are no time file values, use zero not 1
 VelocityRec errVelocity={0,1}; 
 err = timeDep -> GetTimeValue (model -> GetModelTime(), &timeValue); 
 if(err) timeValue = errVelocity;
 }
 
 patVelocity = GetPatValue (p);
 //	patVelocity = GetSmoothVelocity (p);
 
 patVelocity.u *= refScale; 
 patVelocity.v *= refScale; 
 
 if(useEddyUncertainty)
 { // if they gave us a pointer to a boolean fill it in, otherwise don't
 lengthSquaredBeforeTimeFactor = patVelocity.u*patVelocity.u + patVelocity.v*patVelocity.v;
 if(lengthSquaredBeforeTimeFactor < (this -> fEddyV0 * this -> fEddyV0)) *useEddyUncertainty = false; 
 else *useEddyUncertainty = true;
 }
 
 patVelocity.u *= timeValue.u; // magnitude contained in u field only
 patVelocity.v *= timeValue.u; // magnitude contained in u field only
 
 return patVelocity;
 }
 
 
 VelocityRec CATSMover3D_c::GetPatValue(WorldPoint p)
 {
 return fGrid->GetPatValue(p);	// don't use refined grid for movement
 }
 
 VelocityRec CATSMover3D_c::GetSmoothVelocity (WorldPoint p)
 {
 return fGrid->GetSmoothVelocity(p); // don't use refined grid for movement
 }
 */
Boolean CATSMover3D_c::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr)
{
	char uStr[32],sStr[32],verStr[32];
	double lengthU, lengthS;
	VelocityRec velocity = {0.,0.};
	//long segNo,verNum;
	//PtCurMap *map = GetPtCurMap();
	//if (map==nil) return false;
	
	//((PtCurMap_c*)map)->FindNearestBoundary(wp.p,&verNum,&segNo); //AH 03/19/2012 (this needs to be fixed.)
	
	velocity = this->GetPatValue(wp);
	lengthU = sqrt(velocity.u * velocity.u + velocity.v * velocity.v);
	lengthS = this->refScale * lengthU;
	
	StringWithoutTrailingZeros(uStr,lengthU,4);
	StringWithoutTrailingZeros(sStr,lengthS,4);
	
	// a diagnostic to get the boundary point numbers
	/*if(verNum > -1) 
	{
		StringWithoutTrailingZeros(verStr,verNum,4);
		sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s, ptNum: %s]",
				this->className, uStr, sStr, verStr);
	}
	else*/
		sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s]",
				this->className, uStr, sStr);
	return true;
	
}
コード例 #2
0
Boolean ADCPMover_c::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr)
{
	char uStr[32],sStr[32];
	double lengthU, lengthS;
	VelocityRec velocity = {0.,0.};
	Boolean useEddyUncertainty = false;	
	double spillStartDepth = 0.;
	
	if (moverMap->IAm(TYPE_PTCURMAP))
		spillStartDepth = (dynamic_cast<PtCurMap *>(moverMap))->GetSpillStartDepth();
	
	wp.z = spillStartDepth;
	
	//velocity = this->GetPatValue(wp.p);
	velocity = GetVelocityAtPoint(wp);
	lengthU = sqrt(velocity.u * velocity.u + velocity.v * velocity.v);
	lengthS = this->refScale * lengthU;
	
	StringWithoutTrailingZeros(uStr,lengthU,4);
	StringWithoutTrailingZeros(sStr,lengthS,4);
	sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s]",
			this->className, uStr, sStr);
	return true;
	
}
コード例 #3
0
static void IncrementDepth(DialogPtr dialog, float depth)
{
    float incr;
    incr = sIncrementInMeters;
    depth += incr;
    // update dialog value
    char depthstr[30];
    StringWithoutTrailingZeros(depthstr,depth,1);
    mysetitext(dialog,EPDEPTH,depthstr);	// or something
}
コード例 #4
0
ファイル: ComponentMover_c.cpp プロジェクト: liuy0813/PyGnome
Boolean ComponentMover_c::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr)
{
	char str1[32], str2[32], str3[32];
	double length1=0., length2=0., length3 = 0.;
	VelocityRec	pat1Val={0.,0.}, pat2Val={0.,0.}, finalVel;
	OSErr err = 0;
	char errmsg[256];
	
	if (this -> pattern1) {
		pat1Val = this -> pattern1 -> GetPatValue (wp);
		length1 = sqrt(pat1Val.u * pat1Val.u + pat1Val.v * pat1Val.v);
		StringWithoutTrailingZeros(str1,length1,6);
	}
	if (this -> pattern2) {
		pat2Val = this -> pattern2 -> GetPatValue (wp);
		length2 = sqrt(pat2Val.u * pat2Val.u + pat2Val.v * pat2Val.v);
		StringWithoutTrailingZeros(str2,length2,6);
	}
#ifndef pyGNOME	// for now this is not used in pyGNOME, will deal with it later if it becomes an issue
	if (!(this->fOptimize.isOptimizedForStep))
	{
		err = this->SetOptimizeVariables (errmsg, model->GetModelTime(), model->GetTimeStep());
		if (err) return false;
	}
#endif	
	finalVel.u = pat1Val.u * this->fOptimize.pat1ValScale + pat2Val.u * this->fOptimize.pat2ValScale;
	finalVel.v = pat1Val.v * this->fOptimize.pat1ValScale + pat2Val.v * this->fOptimize.pat2ValScale;
	length3 = sqrt(finalVel.u * finalVel.u + finalVel.v * finalVel.v);
	
	StringWithoutTrailingZeros(str1,length1 * this->fOptimize.pat1ValScale,4);
	StringWithoutTrailingZeros(str2,length2 * this->fOptimize.pat2ValScale,4);
	StringWithoutTrailingZeros(str3,length3,4);
	sprintf(diagnosticStr, " [grid: %s, pat1: %s m/s, pat2: %s m/s, total: %s m/s]",
			"component", str1, str2, str3);
	return true;
	
}
コード例 #5
0
void UpdateDisplayWithDepthValuesSet(DialogPtr dialog,DepthValuesSet dvals)
{
    char numstr[30];
    StringWithoutTrailingZeros(numstr,dvals.depth,2);
    mysetitext(dialog,EPDEPTH,numstr);

    //MyFloat2EditText(dialog,EPU,dvals.value.u,4);
    //MyFloat2EditText(dialog,EPV,dvals.value.v,4);
    //MyFloat2EditText(dialog,EPTEMP,dvals.temp,2);
    //MyFloat2EditText(dialog,EPSAL,dvals.sal,2);
    Float2EditText(dialog,EPU,dvals.value.u,6);
    Float2EditText(dialog,EPV,dvals.value.v,6);
    Float2EditText(dialog,EPTEMP,dvals.temp,2);
    Float2EditText(dialog,EPSAL,dvals.sal,2);
}
コード例 #6
0
void DrawProfilesList(DialogPtr w, RECTPTR r, long n)
{
    char s[256];
    DepthValuesSet dvals;

    if(n == sgObjects.numItems-1)
    {
        strcpy(s,"****");
        MyMoveTo(DEPTH_COL-stringwidth(s)/2,r->bottom);
        drawstring(s);
        MyMoveTo(U_COL-stringwidth(s)/2,r->bottom);
        drawstring(s);
        MyMoveTo(V_COL-stringwidth(s)/2,r->bottom);
        drawstring(s);
        MyMoveTo(W_COL-stringwidth(s)/2,r->bottom);
        drawstring(s);
        MyMoveTo(TEMP_COL-stringwidth(s)/2,r->bottom);
        drawstring(s);
        //MyMoveTo(DIR_COL-20,r->bottom); //JLM
        MyMoveTo(SAL_COL-stringwidth(s)/2,r->bottom);
        drawstring(s);
        return;
    }

    sgDepthVals->GetListItem((Ptr)&dvals,n);

    StringWithoutTrailingZeros(s,dvals.depth,1);
    MyMoveTo(DEPTH_COL-stringwidth(s)/2,r->bottom);
    drawstring(s);

    StringWithoutTrailingZeros(s,dvals.value.u,4);
    MyMoveTo(U_COL-stringwidth(s)/2,r->bottom);
    drawstring(s);

    StringWithoutTrailingZeros(s,dvals.value.v,4);
    MyMoveTo(V_COL-stringwidth(s)/2,r->bottom);
    drawstring(s);

    StringWithoutTrailingZeros(s,dvals.w,1);
    MyMoveTo(W_COL-stringwidth(s)/2,r->bottom);
    drawstring(s);

    StringWithoutTrailingZeros(s,dvals.temp,1);
    MyMoveTo(TEMP_COL-stringwidth(s)/2,r->bottom);
    drawstring(s);

    //MyMoveTo(DIR_COL-20,r->bottom);//JLM
    StringWithoutTrailingZeros(s,dvals.sal,1);
    MyMoveTo(SAL_COL-stringwidth(s)/2,r->bottom);
    drawstring(s);

    return;
}
コード例 #7
0
ファイル: TimeGridWind.cpp プロジェクト: JamesMakela/GNOME2
Boolean TimeGridWindRect::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr,double arrowDepth)
{
	char uStr[32],sStr[32],errmsg[256];
	double lengthU, lengthS;
	VelocityRec velocity = {0.,0.};
	OSErr err = 0;
	
	Seconds startTime, endTime, time = model->GetModelTime();
	double timeAlpha;
	long index;
	LongPoint indices;
	
	if(GetNumTimesInFile()>1)
	{
		if (err = this->GetStartTime(&startTime)) return false;	// should this stop us from showing any velocity?
		if (err = this->GetEndTime(&endTime)) /*return false;*/
		{
			if ((time > startTime || time < startTime) && fAllowExtrapolationInTime)
			{
				timeAlpha = 1;
			}
			else
				return false;
		}
		else
			timeAlpha = (endTime - time)/(double)(endTime - startTime);	
	}
	
	{	
		index = this->GetVelocityIndex(wp.p);	// need alternative for curvilinear and triangular
		
		indices = this->GetVelocityIndices(wp.p);
		
		if (index >= 0)
		{
			// Check for constant current 
			if(GetNumTimesInFile()==1 || timeAlpha == 1)
			{
				velocity.u = this->GetStartUVelocity(index);
				velocity.v = this->GetStartVVelocity(index);
			}
			else // time varying current
			{
				velocity.u = timeAlpha*this->GetStartUVelocity(index) + (1-timeAlpha)*this->GetEndUVelocity(index);
				velocity.v = timeAlpha*this->GetStartVVelocity(index) + (1-timeAlpha)*this->GetEndVVelocity(index);
			}
		}
	}
	
	lengthU = sqrt(velocity.u * velocity.u + velocity.v * velocity.v);
	//lengthS = this->fWindScale * lengthU;
	lengthS = lengthU * fVar.fileScaleFactor;
	
	StringWithoutTrailingZeros(uStr,lengthU,4);
	StringWithoutTrailingZeros(sStr,lengthS,4);
	
	sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s], file indices : [%ld, %ld]",
			fVar.userName, uStr, sStr, fNumRows-indices.v-1, indices.h);
	//sprintf(diagnosticStr, " [unscaled: %s m/s, scaled: %s m/s], file indices : [%ld, %ld]",
			//uStr, sStr, fNumRows-indices.v-1, indices.h);
	
	return true;
}
コード例 #8
0
ファイル: TimeGridWind.cpp プロジェクト: JamesMakela/GNOME2
Boolean TimeGridWindCurv::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr, double arrowDepth)
{	
	char uStr[32],sStr[32],errmsg[64];
	double lengthU, lengthS;
	VelocityRec velocity = {0.,0.};
	OSErr err = 0;
	
	Seconds startTime, endTime, time = model->GetModelTime();
	double timeAlpha;
	long index;
	LongPoint indices;
	
	long ptIndex1,ptIndex2,ptIndex3; 
	InterpolationVal interpolationVal;
	
	if (fGrid) 
	{
		// for now just use the u,v at left and bottom midpoints of grid box as velocity over entire gridbox
		index = ((TTriGridVel*)fGrid)->GetRectIndexFromTriIndex(wp.p,fVerdatToNetCDFH,fNumCols+1);// curvilinear grid
		if (index < 0) return 0;
		indices = this->GetVelocityIndices(wp.p);
	}
	
	// Check for constant current 
	if((GetNumTimesInFile()==1 /*&& !(GetNumFiles()>1)*/) || (fEndData.timeIndex == UNASSIGNEDINDEX && time > ((*fTimeHdl)[fStartData.timeIndex] + fTimeShift) && fAllowExtrapolationInTime)  || (fEndData.timeIndex == UNASSIGNEDINDEX && time < ((*fTimeHdl)[fStartData.timeIndex] + fTimeShift) && fAllowExtrapolationInTime))
		//if(GetNumTimesInFile()==1)
	{
		// Calculate the interpolated velocity at the point
		if (index >= 0) 
		{
			velocity.u = INDEXH(fStartData.dataHdl,index).u;
			velocity.v = INDEXH(fStartData.dataHdl,index).v;
		}
		else	// set vel to zero
		{
			velocity.u = 0.;
			velocity.v = 0.;
		}
	}
	else // time varying current 
	{
		// Calculate the time weight factor
		// Calculate the time weight factor
		startTime = (*fTimeHdl)[fStartData.timeIndex] + fTimeShift;
		endTime = (*fTimeHdl)[fEndData.timeIndex] + fTimeShift;
		timeAlpha = (endTime - time)/(double)(endTime - startTime);
		
		// Calculate the interpolated velocity at the point
		if (index >= 0) 
		{
			velocity.u = timeAlpha*INDEXH(fStartData.dataHdl,index).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).u;
			velocity.v = timeAlpha*INDEXH(fStartData.dataHdl,index).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).v;
		}
		else	// set vel to zero
		{
			velocity.u = 0.;
			velocity.v = 0.;
		}
	}
	
	lengthU = sqrt(velocity.u * velocity.u + velocity.v * velocity.v);
	//lengthS = this->fWindScale * lengthU;	// pass this in if there is a dialog scale factor
	lengthS = lengthU * fVar.fileScaleFactor;	
	
	StringWithoutTrailingZeros(uStr,lengthU,4);
	StringWithoutTrailingZeros(sStr,lengthS,4);
	if (indices.h >= 0 && fNumRows-indices.v-1 >=0 && indices.h < fNumCols && fNumRows-indices.v-1 < fNumRows)
	{
		sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s], file indices : [%ld, %ld]",
				fVar.userName, uStr, sStr, fNumRows-indices.v-1, indices.h);
		//sprintf(diagnosticStr, " [unscaled: %s m/s, scaled: %s m/s], file indices : [%ld, %ld]",
				//uStr, sStr, fNumRows-indices.v-1, indices.h);
	}
	else
	{
		sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s]",
				fVar.userName, uStr, sStr);
		//sprintf(diagnosticStr, " [unscaled: %s m/s, scaled: %s m/s]",
				//uStr, sStr);
	}
	
	return true;
}
コード例 #9
0
ListItem TShioTimeValue::GetNthListItem(long n, short indent, short *style, char *text)
{//JLM
	ListItem item = { this, n, indent, 0 };
	text[0] = 0; 
	*style = normal;
	
	/////////////
	if(n == 0)
	{ 	// line 1 station name
		item.indent--;
		sprintf(text,"Station Name: %s",fStationName); 
		return item; 
	}
	n--;
	/////////
	// code goes here, possible check if num max/mins below some threshold and then show all values...
	/*if( 0 <= n && n < this->GetNumValues())
	{
		return TOSSMTimeValue::GetNthListItem(n, indent, style, text); // to show all time values
	}*/
	/////////
	if (this->fStationType == 'C')
	{
		if( 0 <= n && n < this->GetNumEbbFloodValues()) // show only max/mins
		{
			EbbFloodData ebbFloodData;
			DateTimeRec time;
			char *p,timeStr[32],valStr[32],typeStr[32],unitsStr[32]=" kts ";
	
			ebbFloodData = INDEXH(fEbbFloodDataHdl, n);
			switch(ebbFloodData.type)
			{
				case	MinBeforeFlood:
					strcpy(typeStr,"MinBFld ");
					break;
				case	MaxFlood:
					strcpy(typeStr,"MaxFld ");
					break;
				case 	MinBeforeEbb:
					strcpy(typeStr,"MinBEbb ");
					break;
				case	MaxEbb:
					strcpy(typeStr,"MaxEbb ");
					break;
			}
			StringWithoutTrailingZeros(valStr,ebbFloodData.speedInKnots,1);
			SecondsToDate (ebbFloodData.time, &time);
			//time.year = time.year %100;// year 2000 fix , JLM 1/25/99  (two digit year)
			sprintf (timeStr, "%2.2d:%2.2d %02hd/%02hd/%02hd", time.hour, time.minute, time.month, time.day, time.year);
			//Date2String(&time, timeStr);
			//if (p = strrchr(timeStr, ':')) p[0] = 0; // remove seconds
			sprintf(text, "%s%s%s%s",typeStr,valStr,unitsStr,timeStr);
			return item;
		}
	}
	/////////
	else if (this->fStationType == 'H')
	{
		if (n == 0) {
			item.bullet = fHighLowValuesOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
			strcpy(text, "Show High Lows");
			
			return item;
		}
		n--;
		if( 0 <= n && n < this->GetNumHighLowValues() && fHighLowValuesOpen) // show only high/lows
		{
			HighLowData highLowData;
			DateTimeRec time;
			char timeStr[32],valStr[32],typeStr[32],unitsStr[32]=" ft ";
	
			highLowData = INDEXH(fHighLowDataHdl, n);
			switch(highLowData.type)
			{
				case	LowTide:
					strcpy(typeStr,"Low Tide ");
					break;
				case	HighTide:
					strcpy(typeStr,"High Tide ");
					break;
				default:
					strcpy(typeStr,"Unknown ");
					break;
			}
			StringWithoutTrailingZeros(valStr,highLowData.height * fScaleFactor,1);
			SecondsToDate (highLowData.time, &time);
			sprintf (timeStr, "%2.2d:%2.2d %02hd/%02hd/%02hd", time.hour, time.minute, time.month, time.day, time.year);
			sprintf(text, "%s%s%s%s",typeStr,valStr,unitsStr,timeStr);
			return item;
		}

		if (n>=this->GetNumHighLowValues() && fHighLowValuesOpen) n-=this->GetNumHighLowValues();
		
		if (n == 0) {
			item.bullet = fEbbFloodValuesOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
			strcpy(text, "Show Ebb Floods");
			
			return item;
		}
		n--;

		if( (0 <= n && n < 2*(this->GetNumHighLowValues()) - 1 && fEbbFloodValuesOpen)) // show only max/mins, converted from high/lows
		{
			HighLowData startHighLowData,endHighLowData;
			DateTimeRec time;
			double maxMinDeriv;
			Seconds midTime,derivTime;
			long index = floor(n/2.);
			char timeStr[32],valStr[32],typeStr[32],/*unitsStr[32]=" ft/hr ",*/unitsStr[32]=" kts ";
	
			startHighLowData = INDEXH(fHighLowDataHdl, index);
			endHighLowData = INDEXH(fHighLowDataHdl, index+1);
	
			midTime = (endHighLowData.time - startHighLowData.time)/2 + startHighLowData.time;
	
			switch(startHighLowData.type)
			{
				case	LowTide:
					if (fmod(n,2.) == 0)	
					{
						strcpy(typeStr,"MinBFld ");
						derivTime = startHighLowData.time;
					}
					else	
					{
						strcpy(typeStr,"MaxFld ");
						derivTime = midTime;
					}
					break;
				case	HighTide:
					if (fmod(n,2.) == 0)	
					{
						strcpy(typeStr,"MinBEbb ");
						derivTime = startHighLowData.time;
					}
					else 
					{
						strcpy(typeStr,"MaxEbb ");
						derivTime = midTime;
					}
					break;
			}
			maxMinDeriv = GetDeriv(startHighLowData.time, startHighLowData.height,
				endHighLowData.time, endHighLowData.height, derivTime) * fScaleFactor / KNOTSTOMETERSPERSEC;

			StringWithoutTrailingZeros(valStr,maxMinDeriv,1);
			SecondsToDate(derivTime, &time);
			sprintf (timeStr, "%2.2d:%2.2d %02hd/%02hd/%02hd", time.hour, time.minute, time.month, time.day, time.year);
			sprintf(text, "%s%s%s%s",typeStr,valStr,unitsStr,timeStr);
			return item;
		}
	}

	else if (this->fStationType == 'P')
	{
		if (n == 0) {
			item.bullet = fHighLowValuesOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
			strcpy(text, "Show High Lows");
			
			return item;
		}
		n--;
		if( 0 <= n && n < this->GetNumHighLowValues() && fHighLowValuesOpen) // show only high/lows
		{
			HighLowData highLowData;
			DateTimeRec time;
			char timeStr[32],valStr[32],typeStr[32],unitsStr[32]=" ft ";
	
			highLowData = INDEXH(fHighLowDataHdl, n);
			switch(highLowData.type)
			{
				case	LowTide:
					strcpy(typeStr,"Low Tide ");
					break;
				case	HighTide:
					strcpy(typeStr,"High Tide ");
					break;
				default:
					strcpy(typeStr,"Unknown ");
					break;
			}
			StringWithoutTrailingZeros(valStr,highLowData.height * fScaleFactor,1);
			SecondsToDate (highLowData.time, &time);
			sprintf (timeStr, "%2.2d:%2.2d %02hd/%02hd/%02hd", time.hour, time.minute, time.month, time.day, time.year);
			sprintf(text, "%s%s%s%s",typeStr,valStr,unitsStr,timeStr);
			return item;
		}

	}

	item.owner = 0; // not our item
	return item;
}
コード例 #10
0
ListItem GridWindMover::GetNthListItem(long n, short indent, short *style, char *text)
{
	char valStr[64], dateStr[64];
	long numTimesInFile = timeGrid->GetNumTimesInFile();
	ListItem item = { this, n, indent, 0 };
	long mode = model->GetModelMode();
	
	if (n == 0) {
		item.index = I_GRIDWINDNAME;
		if (mode == ADVANCEDMODE) item.bullet = bOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
		strcpy(text,"Wind File: ");
		strcat(text,fFileName);
		if(!bActive)*style = italic; // JLM 6/14/10
		
		return item;
	}
	
	if (bOpen) {
		
		if (mode == ADVANCEDMODE && --n == 0) {
			item.indent++;
			item.index = I_GRIDWINDACTIVE;
			item.bullet = bActive ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			strcpy(text, "Active");
			
			return item;
		}
		
		if (mode == ADVANCEDMODE && --n == 0) {
			item.indent++;
			item.index = I_GRIDWINDSHOWGRID;
			item.bullet = bShowGrid ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			strcpy(text, "Show Grid");
			
			return item;
		}
		
		if (mode == ADVANCEDMODE && --n == 0) {
			item.indent++;
			item.index = I_GRIDWINDSHOWARROWS;
			item.bullet = bShowArrows ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			StringWithoutTrailingZeros(valStr,fArrowScale,6);
			//strcpy(text, "Show Velocity Vectors");
			sprintf(text, "Show Velocities (@ 1 in = %s m/s) ",valStr);
			
			return item;
		}
		
		// release time
		if (timeGrid->GetNumFiles()>1)
		{
			if (--n == 0) {
				//item.indent++;
				//Seconds time = (*fInputFilesHdl)[0].startTime + fTimeShift;
				Seconds time = timeGrid->GetStartTimeValue(0);				
				Secs2DateString2 (time, dateStr);
				/*if(numTimesInFile>0)*/ sprintf (text, "Start Time: %s", dateStr);
				//else sprintf (text, "Time: %s", dateStr);
				return item;
			}
			if (--n == 0) {
				//item.indent++;
				//Seconds time = (*fInputFilesHdl)[GetNumFiles()-1].endTime + fTimeShift;				
				Seconds time = timeGrid->GetStartTimeValue(timeGrid->GetNumFiles()-1);				
				Secs2DateString2 (time, dateStr);
				sprintf (text, "End Time: %s", dateStr);
				return item;
			}
		}
		else
		{
			if (numTimesInFile>0)
			{
				if (--n == 0) {
					//item.indent++;
					//Seconds time = (*fTimeHdl)[0] + fTimeShift;				
					Seconds time = timeGrid->GetTimeValue(0);					// includes the time shift
					Secs2DateString2 (time, dateStr);
					/*if(numTimesInFile>0)*/ sprintf (text, "Start Time: %s", dateStr);
					//else sprintf (text, "Time: %s", dateStr);
					return item;
				}
			}
			if (numTimesInFile>0)
			{
				if (--n == 0) {
					//item.indent++;
					//Seconds time = (*fTimeHdl)[numTimesInFile-1] + fTimeShift;				
					Seconds time = timeGrid->GetTimeValue(numTimesInFile-1) + timeGrid->fTimeShift;				
					Secs2DateString2 (time, dateStr);
					sprintf (text, "End Time: %s", dateStr);
					return item;
				}
			}
		}
		
		if(mode == ADVANCEDMODE && model->IsUncertain())
		{
			if (--n == 0) 
			{
				item.indent++;
				item.index = I_NETCDFWINDUNCERTAIN;
				item.bullet = bUncertaintyPointOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
				strcpy(text, "Uncertainty");
				
				return item;
			}
			
			if(bUncertaintyPointOpen)
			{
				if (--n == 0) 
				{
					item.indent++;
					item.index = I_NETCDFWINDSTARTTIME;
					sprintf(text, "Start Time: %.2f hours",((double)fUncertainStartTime)/3600.);
					return item;
				}
				
				if (--n == 0) 
				{
					item.indent++;
					item.index = I_NETCDFWINDDURATION;
					sprintf(text, "Duration: %.2f hr", (float)(fDuration / 3600.0));
					return item;
				}
				
				if (--n == 0) 
				{
					item.indent++;
					item.index = I_NETCDFWINDSPEEDSCALE;
					sprintf(text, "Speed Scale: %.2f ", fSpeedScale);
					return item;
				}
				if (--n == 0) 
				{
					item.indent++;
					item.index = I_NETCDFWINDANGLESCALE;
					sprintf(text, "Angle Scale: %.2f ", fAngleScale);
					return item;
				}
			}
		}
	}
	
	item.owner = 0;
	
	return item;
}
コード例 #11
0
ListItem GridCurrentMover::GetNthListItem(long n, short indent, short *style, char *text)
{
	char valStr[64], dateStr[64];
	long numTimesInFile = timeGrid->GetNumTimesInFile();
	//long numTimesInFile = 0;
	ListItem item = { this, 0, indent, 0 };
	
	if (n == 0) {
		item.index = I_GRIDCURRENTNAME;
		item.bullet = bOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
		sprintf(text, "Currents: \"%s\"", timeGrid->fVar.userName);
		if(!bActive)*style = italic; // JLM 6/14/10
		
		return item;
	}
	
	if (bOpen) {
		
		
		if (--n == 0) {
			item.index = I_GRIDCURRENTACTIVE;
			item.bullet = bActive ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			strcpy(text, "Active");
			item.indent++;
			return item;
		}
		
		if (--n == 0) {
			item.index = I_GRIDCURRENTGRID;
			item.bullet = fVar.bShowGrid ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			sprintf(text, "Show Grid");
			item.indent++;
			return item;
		}
		
		if (--n == 0) {
			item.index = I_GRIDCURRENTARROWS;
			item.bullet = fVar.bShowArrows ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			StringWithoutTrailingZeros(valStr,fVar.arrowScale,6);
			//sprintf(text, "Show Velocities (@ 1 in = %s m/s) ", valStr);
			if (fVar.gridType==TWO_D)
				sprintf(text, "Show Velocities (@ 1 in = %s m/s)", valStr);
			else
			{
				if (fVar.arrowDepth>=0)
					sprintf(text, "Show Velocities (@ 1 in = %s m/s) at %g m", valStr, fVar.arrowDepth);
				else
					sprintf(text, "Show Velocities (@ 1 in = %s m/s) at bottom", valStr);
			}
			item.indent++;
			return item;
		}
		
		if (--n == 0) {
			item.index = I_GRIDCURRENTSCALE;
			StringWithoutTrailingZeros(valStr,fVar.curScale,6);
			sprintf(text, "Multiplicative Scalar: %s", valStr);
			//item.indent++;
			return item;
		}
		
		// release time
		if (timeGrid->GetNumFiles()>1)
		{
			if (--n == 0) {
				//item.indent++;
				//Seconds time = (*fInputFilesHdl)[0].startTime + fTimeShift;
				Seconds time = timeGrid->GetStartTimeValue(0);				
				Secs2DateString2 (time, dateStr);
				/*if(numTimesInFile>0)*/ sprintf (text, "Start Time: %s", dateStr);
				//else sprintf (text, "Time: %s", dateStr);
				return item;
			}
			if (--n == 0) {
				//item.indent++;
				//Seconds time = (*fInputFilesHdl)[GetNumFiles()-1].endTime + fTimeShift;				
				Seconds time = timeGrid->GetStartTimeValue(timeGrid->GetNumFiles()-1);				
				Secs2DateString2 (time, dateStr);
				sprintf (text, "End Time: %s", dateStr);
				return item;
			}
		}
		else
		{
			if (numTimesInFile>0)
			{
				if (--n == 0) {
					//item.indent++;
					//Seconds time = (*fTimeHdl)[0] + fTimeShift;				
					Seconds time = timeGrid->GetTimeValue(0);					// includes the time shift
					Secs2DateString2 (time, dateStr);
					/*if(numTimesInFile>0)*/ sprintf (text, "Start Time: %s", dateStr);
					//else sprintf (text, "Time: %s", dateStr);
					return item;
				}
			}
			
			if (numTimesInFile>0)
			{
				if (--n == 0) {
					//item.indent++;
					//Seconds time = (*fTimeHdl)[numTimesInFile-1] + fTimeShift;				
					Seconds time = timeGrid->GetTimeValue(numTimesInFile-1) + timeGrid->fTimeShift;				
					Secs2DateString2 (time, dateStr);
					sprintf (text, "End Time: %s", dateStr);
					return item;
				}
			}
		}
		
		
		if(model->IsUncertain())
		{
			if (--n == 0) {
				item.index = I_GRIDCURRENTUNCERTAINTY;
				item.bullet = fVar.bUncertaintyPointOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
				strcpy(text, "Uncertainty");
				item.indent++;
				return item;
			}
			
			if (fVar.bUncertaintyPointOpen) {
				
				if (--n == 0) {
					item.index = I_GRIDCURRENTALONGCUR;
					item.indent++;
					StringWithoutTrailingZeros(valStr,fVar.alongCurUncertainty*100,6);
					sprintf(text, "Along Current: %s %%",valStr);
					return item;
				}
				
				if (--n == 0) {
					item.index = I_GRIDCURRENTCROSSCUR;
					item.indent++;
					StringWithoutTrailingZeros(valStr,fVar.crossCurUncertainty*100,6);
					sprintf(text, "Cross Current: %s %%",valStr);
					return item;
				}
				
				/*if (--n == 0) {
				 item.index = I_GRIDCURRENTMINCURRENT;
				 item.indent++;
				 StringWithoutTrailingZeros(valStr,fVar.uncertMinimumInMPS,6);
				 sprintf(text, "Current Minimum: %s m/s",valStr);
				 return item;
				 }*/
				
				if (--n == 0) {
					item.index = I_GRIDCURRENTSTARTTIME;
					item.indent++;
					StringWithoutTrailingZeros(valStr,fVar.startTimeInHrs,6);
					sprintf(text, "Start Time: %s hours",valStr);
					return item;
				}
				
				if (--n == 0) {
					item.index = I_GRIDCURRENTDURATION;
					//item.bullet = BULLET_DASH;
					item.indent++;
					StringWithoutTrailingZeros(valStr,fVar.durationInHrs,6);
					sprintf(text, "Duration: %s hours",valStr);
					return item;
				}
				
				
			}
			
		}  // uncertainty is on
		
	} // bOpen
	
	item.owner = 0;
	
	return item;
}
コード例 #12
0
ListItem TRandom3D::GetNthListItem(long n, short indent, short *style, char *text)
{
	ListItem item = { dynamic_cast<TClassID *>(this), 0, indent, 0 };
	char valStr[32],valStr2[32];
	
	if (n == 0) {
		item.index = I_RANDOMNAME;
		item.bullet = bOpen ? BULLET_OPENTRIANGLE : BULLET_CLOSEDTRIANGLE;
		sprintf(text, "Random3D: \"%s\"", className);
		if(!bActive)*style = italic; // JLM 6/14/10
		
		return item;
	}
	
	n -= 1;
	item.indent++;
	
	if (bOpen) {
		if (n == 0) {
			item.index = I_RANDOMACTIVE;
			item.bullet = bActive ? BULLET_FILLEDBOX : BULLET_EMPTYBOX;
			strcpy(text, "Active");
			
			return item;
		}
		
		n -= 1;
		
		if (n == 0) {
			item.index = I_RANDOMAREA;
			StringWithoutTrailingZeros(valStr,fDiffusionCoefficient,0);
			sprintf(text, "%s cm**2/sec (surface)", valStr);
			
			return item;
		}
		
		n -= 1;
		
		if(model->IsUncertain())
		{
			if (n == 0) {
				item.index = I_RANDOMUFACTOR;
				StringWithoutTrailingZeros(valStr,fUncertaintyFactor,0);
				sprintf(text, "Uncertainty factor: %s", valStr);
				
				return item;
			}
			
			n -= 1;
		}
		
		if (n == 0) {
			item.index = I_RANDOMVERTAREA;
			StringWithoutTrailingZeros(valStr,fVerticalDiffusionCoefficient,0);
			StringWithoutTrailingZeros(valStr2,fHorizontalDiffusionCoefficient,0);
			if (bUseDepthDependentDiffusion)
				sprintf(text, "vert = f(z), %s cm**2/sec (horiz)", valStr2);
			else
				sprintf(text, "%s cm**2/sec (vert), %s cm**2/sec (horiz)", valStr, valStr2);		
			
			return item;
		}
		
		n -= 1;
		
	}
	
	item.owner = 0;
	
	return item;
}
コード例 #13
0
static void MyFloat2EditText(DialogPtr dialog, short itemnum,float num,short numdec)
{
    char numstr[30];
    StringWithoutTrailingZeros(numstr,num,numdec);
    mysetitext(dialog,itemnum,numstr);
}
コード例 #14
0
Boolean NetCDFWindMoverCurv_c::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr)
{	// code goes here, this is triangle code, not curvilinear
	char uStr[32],sStr[32],errmsg[64];
	double lengthU, lengthS;
	VelocityRec velocity = {0.,0.};
	OSErr err = 0;
	
	Seconds startTime, endTime, time = model->GetModelTime();
	double timeAlpha;
	long index;
	LongPoint indices;
	
	long ptIndex1,ptIndex2,ptIndex3; 
	InterpolationVal interpolationVal;
	
	// maybe should set interval right after reading the file...
	// then wouldn't have to do it here
	if (!bActive) return 0; 
	if (!bShowArrows && !bShowGrid) return 0;
//	err = dynamic_cast<NetCDFWindMoverCurv *>(this) -> SetInterval(errmsg);	// minus AH 07/17/2012
	//err = dynamic_cast<NetCDFWindMoverCurv *>(this) -> SetInterval(errmsg, model->GetStartTime(), model->GetModelTime()); // AH 07/17/2012
	err = dynamic_cast<NetCDFWindMoverCurv *>(this) -> SetInterval(errmsg, model->GetModelTime()); // AH 07/17/2012
	
	if(err) return false;
	
	if (fGrid) 
	{
		// for now just use the u,v at left and bottom midpoints of grid box as velocity over entire gridbox
		index = ((TTriGridVel*)fGrid)->GetRectIndexFromTriIndex(wp.p,fVerdatToNetCDFH,fNumCols+1);// curvilinear grid
		if (index < 0) return 0;
		indices = this->GetVelocityIndices(wp.p);
	}
	
	// Check for constant current 
	if((dynamic_cast<NetCDFWindMoverCurv *>(this)->GetNumTimesInFile()==1 /*&& !(GetNumFiles()>1)*/) || (fEndData.timeIndex == UNASSIGNEDINDEX && time > ((*fTimeHdl)[fStartData.timeIndex] + fTimeShift) && fAllowExtrapolationOfWinds)  || (fEndData.timeIndex == UNASSIGNEDINDEX && time < ((*fTimeHdl)[fStartData.timeIndex] + fTimeShift) && fAllowExtrapolationOfWinds))
		//if(GetNumTimesInFile()==1)
	{
		// Calculate the interpolated velocity at the point
		if (index >= 0) 
		{
			velocity.u = INDEXH(fStartData.dataHdl,index).u;
			velocity.v = INDEXH(fStartData.dataHdl,index).v;
		}
		else	// set vel to zero
		{
			velocity.u = 0.;
			velocity.v = 0.;
		}
	}
	else // time varying current 
	{
		// Calculate the time weight factor
		// Calculate the time weight factor
		startTime = (*fTimeHdl)[fStartData.timeIndex] + fTimeShift;
		endTime = (*fTimeHdl)[fEndData.timeIndex] + fTimeShift;
		timeAlpha = (endTime - time)/(double)(endTime - startTime);
		
		// Calculate the interpolated velocity at the point
		if (index >= 0) 
		{
			velocity.u = timeAlpha*INDEXH(fStartData.dataHdl,index).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).u;
			velocity.v = timeAlpha*INDEXH(fStartData.dataHdl,index).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,index).v;
		}
		else	// set vel to zero
		{
			velocity.u = 0.;
			velocity.v = 0.;
		}
	}
	
	lengthU = sqrt(velocity.u * velocity.u + velocity.v * velocity.v);
	//lengthS = this->fWindScale * lengthU;
	lengthS = this->fWindScale * lengthU;
	
	StringWithoutTrailingZeros(uStr,lengthU,4);
	StringWithoutTrailingZeros(sStr,lengthS,4);
	if (indices.h >= 0 && fNumRows-indices.v-1 >=0 && indices.h < fNumCols && fNumRows-indices.v-1 < fNumRows)
	{
		sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s], file indices : [%ld, %ld]",
				this->className, uStr, sStr, fNumRows-indices.v-1, indices.h);
	}
	else
	{
		sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s]",
				this->className, uStr, sStr);
	}
	
	return true;
}
コード例 #15
0
Boolean TriCurMover_c::VelocityStrAtPoint(WorldPoint3D wp, char *diagnosticStr)
{
	char uStr[32],sStr[32],errmsg[64];
	double lengthU, lengthS;
	VelocityRec velocity = {0.,0.};
	OSErr err = 0;
	
	Seconds startTime, endTime, time = model->GetModelTime();
	double timeAlpha, depthAlpha;
	float topDepth, bottomDepth/*, totalDepth=0*/;
	long depthIndex1,depthIndex2;	// default to -1?
	//WorldPoint refPoint = wp.p;
	
	long triNum, ptIndex; 
	
	// maybe should set interval right after reading the file...
	// then wouldn't have to do it here
	if (!bActive) return 0; 
	err = dynamic_cast<TriCurMover *>(this) -> SetInterval(errmsg, model->GetModelTime()); // AH 07/17/2012
	
	if(err) return false;
	
	
	//triNum = WhatTriAmIIn(refPoint);
	triNum = WhatTriAmIIn(wp.p);
	if (triNum < 0) return false;	// probably an error
	
	//ptIndex = triNum*fVar.maxNumDepths; 
	//ptIndex = (*fDepthDataInfo)[triNum].indexToDepthData;
	
	GetDepthIndices(triNum,fVar.arrowDepth,&depthIndex1,&depthIndex2);
	
	if (depthIndex1==UNASSIGNEDINDEX && depthIndex2==UNASSIGNEDINDEX)
		return false;	// no value for this point at chosen depth, should show zero?
	
	if (depthIndex2!=UNASSIGNEDINDEX)
	{
		//if (fDepthDataInfo) totalDepth = INDEXH(fDepthDataInfo,i).totalDepth;	// depth from input file (?) at triangle center
		//else {printError("Problem with depth data in TriCurMover::Draw"); return false;}
		// Calculate the depth weight factor
		topDepth = INDEXH(fDepthsH,depthIndex1);
		bottomDepth = INDEXH(fDepthsH,depthIndex2);
		depthAlpha = (bottomDepth - fVar.arrowDepth)/(double)(bottomDepth - topDepth);
	}
	
	// Check for constant current 
	//if(GetNumTimesInFile()==1 && !(GetNumFiles()>1))
	if(dynamic_cast<TriCurMover *>(this)->GetNumTimesInFile()==1)
	{
		// Calculate the interpolated velocity at the point
		//if (ptIndex >= 0) 
		if(depthIndex2==UNASSIGNEDINDEX) // surface velocity or special cases
		{
			velocity.u = INDEXH(fStartData.dataHdl,depthIndex1).u;
			velocity.v = INDEXH(fStartData.dataHdl,depthIndex1).v;
		}
		else	// if negative corresponds to negative ntri, set vel to zero
		{
			velocity.u = depthAlpha*INDEXH(fStartData.dataHdl,depthIndex1).u+(1-depthAlpha)*INDEXH(fStartData.dataHdl,depthIndex2).u;
			velocity.v = depthAlpha*INDEXH(fStartData.dataHdl,depthIndex1).v+(1-depthAlpha)*INDEXH(fStartData.dataHdl,depthIndex2).v;
			//velocity.u = 0.;
			//velocity.v = 0.;
		}
	}
	else // time varying current 
	{
		// Calculate the time weight factor
		//if (GetNumFiles()>1 && fOverLap)
		//startTime = fOverLapStartTime;
		//else
		startTime = (*fTimeDataHdl)[fStartData.timeIndex].time;
		endTime = (*fTimeDataHdl)[fEndData.timeIndex].time;
		timeAlpha = (endTime - time)/(double)(endTime - startTime);
		
		// Calculate the interpolated velocity at the point
		//if (ptIndex >= 0) 
		if(depthIndex2==UNASSIGNEDINDEX) // surface velocity or special cases
		{
			velocity.u = timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).u;
			velocity.v = timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).v;
		}
		else	// if negative corresponds to negative ntri, set vel to zero
		{
			//velocity.u = 0.;
			//velocity.v = 0.;
			velocity.u = depthAlpha*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).u);
			velocity.u += (1-depthAlpha)*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex2).u + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex2).u);
			velocity.v = depthAlpha*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex1).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex1).v);
			velocity.v += (1-depthAlpha)*(timeAlpha*INDEXH(fStartData.dataHdl,depthIndex2).v + (1-timeAlpha)*INDEXH(fEndData.dataHdl,depthIndex2).v);
		}
	}
	//velocity.u *= fVar.curScale; 
	//velocity.v *= fVar.curScale; 
	
	
	lengthU = sqrt(velocity.u * velocity.u + velocity.v * velocity.v);
	lengthS = this->fVar.curScale * lengthU;
	
	StringWithoutTrailingZeros(uStr,lengthU,4);
	StringWithoutTrailingZeros(sStr,lengthS,4);
	sprintf(diagnosticStr, " [grid: %s, unscaled: %s m/s, scaled: %s m/s]",
			this->className, uStr, sStr);
	
	return true;
}