Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-hennen committed Nov 3, 2017
2 parents 0bcad20 + 56c3ea0 commit 22720a6
Show file tree
Hide file tree
Showing 134 changed files with 5,104 additions and 4,527 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ py_gnome/build/**/*
py_gnome/gnome.utilities.egg-info/*
py_gnome/pyGnome.egg-info/*
py_gnome/gnome/pyGnome.egg-info/*
<<<<<<< Upstream, based on origin/develop
py_gnome/documentation/_build/
=======
>>>>>>> 60dffaa replaced gitignore with develop ver

# ignore sphinx built docs
py_gnome/documentation/_build/
Expand Down
2 changes: 1 addition & 1 deletion InstallingWithAnaconda.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Add the NOAA-ORR-ERD channel::

Add the conda-forge channel::

> conda config --add channels conda forge
> conda config --add channels conda-forge

When you add a channel to conda, it puts it at the top of the list. So now when you
install a package, conda will first look in conda-forge, then NOAA-ORR-ERD, and
Expand Down
8 changes: 5 additions & 3 deletions conda_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ netCDF4=1.2.7
awesome-slugify>=1.6
regex>=2014.12
unidecode>=0.04.19
pyshp>=1.2
pyugrid=0.2.3
pysgrid=0.3.5
pyshp=1.2.10
gridded==0.0.9

# NOAA maintained packages
unit_conversion=2.5.5
Expand All @@ -42,7 +41,10 @@ cython=0.24.1

# nice to have for development, not required to run
pytest
pytest-cov
pytest-timeout
testfixtures

matplotlib
sphinx
sphinx_rtd_theme
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import numpy as np

from pysgrid import SGrid
from gnome.environment.grid_property import GriddedProp

import os
from datetime import datetime, timedelta
Expand All @@ -20,12 +18,15 @@
from gnome.movers.py_current_movers import PyCurrentMover

from gnome.outputters import Renderer, NetCDFOutput

from gnome.environment.gridded_objects_base import Grid_S, Variable

x, y = np.mgrid[-30:30:61j, -30:30:61j]
y = np.ascontiguousarray(y.T)
x = np.ascontiguousarray(x.T)
# y += np.sin(x) / 1
# x += np.sin(x) / 5
g = SGrid(node_lon=x,
g = Grid_S(node_lon=x,
node_lat=y)
g.build_celltree()
t = datetime(2000, 1, 1, 0, 0)
Expand All @@ -49,8 +50,8 @@
# value[:,0] = x
# value[:,1] = y

vels_x = GriddedProp(name='v_x', units='m/s', time=[t], grid=g, data=vx)
vels_y = GriddedProp(name='v_y', units='m/s', time=[t], grid=g, data=vy)
vels_x = Variable(name='v_x', units='m/s', time=[t], grid=g, data=vx)
vels_y = Variable(name='v_y', units='m/s', time=[t], grid=g, data=vy)
vg = GridCurrent(variables=[vels_y, vels_x], time=[t], grid=g, units='m/s')
point = np.zeros((1, 2))
print vg.at(point, t)
Expand Down
125 changes: 70 additions & 55 deletions gnome1/gui_gnome/CLASSES.CPP
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ short M51Click(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)
// should dispose if exists ?
gEditContourLevels = (DOUBLEH)_NewHandleClear(0);
// code goes here, should init fContourLevelsH if nil
if((dynamic_cast<PtCurMap *>(gDialogTMap)) -> fContourLevelsH)
if((dynamic_cast<PtCurMap *>(gDialogTMap)) -> fContourLevelsH)
{
gEditContourLevels = (dynamic_cast<PtCurMap *>(gDialogTMap)) -> fContourLevelsH;
if(_HandToHand((Handle *)&gEditContourLevels))
Expand Down Expand Up @@ -656,21 +656,28 @@ OSErr M50Init(DialogPtr dialog, VOIDPTR data)

Float2EditText(dialog,M50REFLOATTIME, gDialogTMap -> fRefloatHalfLifeInHrs , 4);

SetButton (dialog, M25WANTEDCHANGEBOUNDS, dialogPtCurMap -> fUseBitMapBounds); // !EquaLWRect()

//SetButton (dialog, M25REPLACEMAP, false);

wp.pLat = dialogPtCurMap -> fBitMapBounds.hiLat;
wp.pLong = dialogPtCurMap -> fBitMapBounds.loLong;
LL2EditTexts (dialog, M25TOPLATDEGREES, &wp);
if (gDialogTMap ->IAm(TYPE_MAP3D))
{
SetButton (dialog, M25WANTEDCHANGEBOUNDS, false); // !EquaLWRect()
ShowHideBounds(dialog); // for now using same enum values as M25 vector map dialog
ShowHideDialogItem(dialog,M25WANTEDCHANGEBOUNDS,false);
ShowHideDialogItem(dialog,M25FROST1,false);
}
else
{
SetButton (dialog, M25WANTEDCHANGEBOUNDS, dialogPtCurMap -> fUseBitMapBounds); // !EquaLWRect()

wp.pLat = dialogPtCurMap -> fBitMapBounds.loLat;
wp.pLong = dialogPtCurMap -> fBitMapBounds.hiLong;
LL2EditTexts (dialog, M25BOTTOMLATDEGREES, &wp);
wp.pLat = dialogPtCurMap -> fBitMapBounds.hiLat;
wp.pLong = dialogPtCurMap -> fBitMapBounds.loLong;
LL2EditTexts (dialog, M25TOPLATDEGREES, &wp);

//ShowHideBitMapBounds(dialog);
ShowHideBounds(dialog); // for now using same enum values as M25 vector map dialog
wp.pLat = dialogPtCurMap -> fBitMapBounds.loLat;
wp.pLong = dialogPtCurMap -> fBitMapBounds.hiLong;
LL2EditTexts (dialog, M25BOTTOMLATDEGREES, &wp);

//ShowHideBitMapBounds(dialog);
ShowHideBounds(dialog); // for now using same enum values as M25 vector map dialog
}
if (gDialogTMap ->IAm(TYPE_OSSMMAP)) // don't show refloat stuff since it varies with each grid cell
{
ShowHideDialogItem(dialog,M50REFLOATLABEL,false);
Expand Down Expand Up @@ -703,59 +710,67 @@ short M50Click(DialogPtr dialog, short itemNum, long lParam, VOIDPTR data)

case M50OK:
gDialogTMap -> fRefloatHalfLifeInHrs = EditText2Float(dialog,M50REFLOATTIME);

tempUseBounds = GetButton (dialog, M25WANTEDCHANGEBOUNDS);

if (tempUseBounds != dialogPtCurMap -> fUseBitMapBounds || tempUseBounds == true)
if (gDialogTMap ->IAm(TYPE_MAP3D))
{
needToResetBitMap = true;
}

if(tempUseBounds)
else
{
long oneSecond = (1000000/3600);
// retrieve the extendedBounds
err = EditTexts2LL(dialog, M25TOPLATDEGREES, &p,TRUE);
if(err)break;
err = EditTexts2LL(dialog, M25BOTTOMLATDEGREES, &p2,TRUE);
if(err)break;

// get original map bounds for comparison
//origBounds = dialogTVectorMap -> fMapBounds; // if use GetMapBounds() may return extended bounds
origBounds = gDialogTMap -> fMapBounds; // if use GetMapBounds() may return extended bounds

// check extended bounds (oneSecond handles accuracy issue in reading from dialog)
if (p.pLat > origBounds.hiLat + oneSecond || p2.pLat< origBounds.loLat - oneSecond
|| p.pLong < origBounds.loLong - oneSecond || p2.pLong > origBounds.hiLong + oneSecond)

if (tempUseBounds != dialogPtCurMap -> fUseBitMapBounds || tempUseBounds == true)
{
printError("The bitmap bounds must be less than the original bounds.");
return 0;
needToResetBitMap = true;
}

if(tempUseBounds)
{
long oneSecond = (1000000/3600);
// retrieve the extendedBounds
err = EditTexts2LL(dialog, M25TOPLATDEGREES, &p,TRUE);
if(err)break;
err = EditTexts2LL(dialog, M25BOTTOMLATDEGREES, &p2,TRUE);
if(err)break;

// just in case of round off
p.pLat = _min(p.pLat,origBounds.hiLat);
p.pLong = _max(p.pLong,origBounds.loLong);
p2.pLat = _max(p2.pLat,origBounds.loLat);
p2.pLong = _min(p2.pLong,origBounds.hiLong);
}
// get original map bounds for comparison
//origBounds = dialogTVectorMap -> fMapBounds; // if use GetMapBounds() may return extended bounds
origBounds = gDialogTMap -> fMapBounds; // if use GetMapBounds() may return extended bounds

// check extended bounds (oneSecond handles accuracy issue in reading from dialog)
if (p.pLat > origBounds.hiLat + oneSecond || p2.pLat< origBounds.loLat - oneSecond
|| p.pLong < origBounds.loLong - oneSecond || p2.pLong > origBounds.hiLong + oneSecond)
{
printError("The bitmap bounds must be less than the original bounds.");
return 0;
}

// just in case of round off
p.pLat = _min(p.pLat,origBounds.hiLat);
p.pLong = _max(p.pLong,origBounds.loLong);
p2.pLat = _max(p2.pLat,origBounds.loLat);
p2.pLong = _min(p2.pLong,origBounds.hiLong);
}

dialogPtCurMap -> fUseBitMapBounds = GetButton (dialog, M25WANTEDCHANGEBOUNDS);
dialogPtCurMap -> fUseBitMapBounds = GetButton (dialog, M25WANTEDCHANGEBOUNDS);

if (dialogPtCurMap -> fUseBitMapBounds)
{
dialogPtCurMap -> fBitMapBounds.hiLat = p.pLat;
dialogPtCurMap -> fBitMapBounds.loLong = p.pLong;
dialogPtCurMap -> fBitMapBounds.loLat = p2.pLat;
dialogPtCurMap -> fBitMapBounds.hiLong = p2.pLong;
//err = dialogPtCurMap -> MakeBitmaps();
//if (!err) ChangeCurrentView(UnionWRect(settings.currentView, AddWRectBorders(dialogPtCurMap -> fBitMapBounds, 10)), TRUE, TRUE);
}
else
dialogPtCurMap -> fBitMapBounds = dialogPtCurMap -> GetMapBounds();
if (dialogPtCurMap -> fUseBitMapBounds)
{
dialogPtCurMap -> fBitMapBounds.hiLat = p.pLat;
dialogPtCurMap -> fBitMapBounds.loLong = p.pLong;
dialogPtCurMap -> fBitMapBounds.loLat = p2.pLat;
dialogPtCurMap -> fBitMapBounds.hiLong = p2.pLong;
//err = dialogPtCurMap -> MakeBitmaps();
//if (!err) ChangeCurrentView(UnionWRect(settings.currentView, AddWRectBorders(dialogPtCurMap -> fBitMapBounds, 10)), TRUE, TRUE);
}
else
dialogPtCurMap -> fBitMapBounds = dialogPtCurMap -> GetMapBounds();

if (needToResetBitMap)
{
err = dialogPtCurMap -> MakeBitmaps();
if (!err) ChangeCurrentView(AddWRectBorders(dialogPtCurMap -> fBitMapBounds, 10), TRUE, TRUE);
if (needToResetBitMap)
{
err = dialogPtCurMap -> MakeBitmaps();
if (!err) ChangeCurrentView(AddWRectBorders(dialogPtCurMap -> fBitMapBounds, 10), TRUE, TRUE);
}
}

return itemNum;
Expand Down
9 changes: 6 additions & 3 deletions gnome1/gui_gnome/NetCDFWindMoverCurv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ OSErr NetCDFWindMoverCurv::ReadTimeData(long index,VelocityFH *velocityH, char*
}
/*if (status != NC_NOERR)*//*err = -1; goto done;*/}} // don't require
//if (status != NC_NOERR) {err = -1; goto done;} // don't require
status = nc_get_att_float(ncid, wind_ucmp_id, "scale_factor", &scale_factor);
//if (status != NC_NOERR) {err = -1; goto done;} // don't require scale factor

}

status = nc_inq_attlen(ncid, wind_ucmp_id, "units", &velunit_len);
Expand All @@ -745,7 +748,6 @@ OSErr NetCDFWindMoverCurv::ReadTimeData(long index,VelocityFH *velocityH, char*
}
}


status = nc_close(ncid);
if (status != NC_NOERR) {err = -1; goto done;}

Expand Down Expand Up @@ -834,8 +836,9 @@ void NetCDFWindMoverCurv::Draw(Rect r, WorldRect view)
OSErr err = 0;
char errmsg[256];

RGBForeColor(&colors[PURPLE]);

//RGBForeColor(&colors[PURPLE]);
RGBForeColor(&fColor);

if(bShowArrows || bShowGrid)
{
if (bShowGrid) // make sure to draw grid even if don't draw arrows
Expand Down
11 changes: 9 additions & 2 deletions gnome1/gui_gnome/TimeValuesIOPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,15 @@ TOSSMTimeValue* CreateTOSSMTimeValue(TMover *theOwner,char* path, char* shortFil
else
{
#if TARGET_API_MAC_CARBON
err = ConvertTraditionalPathToUnixPath((const char *) path, outPath, kMaxNameLen) ;
if (!err) strcpy(path,outPath);
if(model && model->fWizard && model->fWizard->PathIsWizardResource(path))
{
// don't mess up the resource path
}
else
{
err = ConvertTraditionalPathToUnixPath((const char *) path, outPath, kMaxNameLen) ;
if (!err) strcpy(path,outPath);
}
#endif

if (IsTimeFile(path) || IsHydrologyFile(path) || IsOSSMTimeFile(path, &unitsIfKnownInAdvance))
Expand Down
2 changes: 1 addition & 1 deletion lib_gnome/CurrentMover_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ OSErr CurrentMover_c::AllocateUncertainty(int numLESets, int* LESetsSizesList) /

this->DisposeUncertainty(); // get rid of any old values

if (numLESets == 0) return -1; // shouldn't happen - if we get here there should be an uncertainty set
//if (numLESets == 0) return -1; // shouldn't happen - if we get here there should be an uncertainty set - unless there is no spill...

if(!(fLESetSizesH = (LONGH)_NewHandle(sizeof(long)*numLESets)))goto errHandler;

Expand Down
16 changes: 14 additions & 2 deletions lib_gnome/GridCurrentMover_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,14 @@ OSErr GridCurrentMover_c::GetScaledVelocities(Seconds model_time, VelocityFRec *

LongPointHdl GridCurrentMover_c::GetPointsHdl(void)
{
return timeGrid->fGrid->GetPointsHdl();
if (timeGrid->IsRegularGrid())
{
return timeGrid->GetPointsHdl();
}
else
{
return timeGrid->fGrid->GetPointsHdl();
}
}

TopologyHdl GridCurrentMover_c::GetTopologyHdl(void)
Expand All @@ -557,7 +564,12 @@ GridCellInfoHdl GridCurrentMover_c::GetCellDataHdl(void)
WORLDPOINTH GridCurrentMover_c::GetTriangleCenters(void)
{ // should rename this function...
if (IsTriangleGrid())
return timeGrid->fGrid->GetCenterPointsHdl();
{
if (IsDataOnCells())
return timeGrid->fGrid->GetCenterPointsHdl();
else
return timeGrid->fGrid->GetWorldPointsHdl();
}
else
return timeGrid->GetCellCenters();
}
Expand Down
1 change: 1 addition & 0 deletions lib_gnome/GridCurrentMover_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class DLL_API GridCurrentMover_c : virtual public CurrentMover_c {
long GetNumPoints(void);
bool IsTriangleGrid(){return timeGrid->IsTriangleGrid();}
bool IsDataOnCells(){return timeGrid->IsDataOnCells();}
bool IsRegularGrid(){return timeGrid->IsRegularGrid();}

OSErr get_move(int n, Seconds model_time, Seconds step_len, WorldPoint3D* ref, WorldPoint3D* delta, short* LE_status, LEType spillType, long spill_ID);

Expand Down
1 change: 1 addition & 0 deletions lib_gnome/GridVel_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GridVel_c {
virtual InterpolationValBilinear GetBilinearInterpolationValues(WorldPoint ref){InterpolationValBilinear ival; memset(&ival,0,sizeof(ival)); return ival;}
virtual InterpolationVal GetInterpolationValues(WorldPoint ref){InterpolationVal ival; memset(&ival,0,sizeof(ival)); return ival;}
virtual LongPointHdl GetPointsHdl(void){return 0;}
virtual WORLDPOINTH GetWorldPointsHdl(void){return 0;}
virtual TopologyHdl GetTopologyHdl(void){return 0;}
virtual WORLDPOINTH GetCenterPointsHdl(void){return 0;}
virtual double GetDepthAtPoint(WorldPoint p){return 0;}
Expand Down
19 changes: 17 additions & 2 deletions lib_gnome/OSSMTimeValue_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ OSErr OSSMTimeValue_c::ReadNDBCWind(vector<string> &linesInFile, long numHeaderL
if (lineStream.fail()) {
// scan will allow comment at end of line, for now just ignore
err = -1;
TechError("OSSMTimeValue_c::ReadTimeValues()", "scan data values", 0);
TechError("OSSMTimeValue_c::ReadNDBCWind()", "scan data values", 0);
goto done;
}

Expand Down Expand Up @@ -847,13 +847,28 @@ OSErr OSSMTimeValue_c::ReadTimeValues(char *path, short format, short unitsIfKno
//strcpy(this->fileName, path); // for now use full path
//#endif

#ifndef pyGNOME
// location files need special case code that is in ReadFileContents
CHARH f = 0;
if ((err = ReadFileContents(TERMINATED,0, 0, path, 0, 0, &f)) != 0) {
TechError("TOSSMTimeValue::ReadTimeValues()", "ReadFileContents()", 0);
return -1;
}
vector<string> linesInFile;
if (ReadLinesInFile(path, linesInFile)) {
if (ReadLinesInBuffer(f, linesInFile)) {
linesInFile = rtrim_empty_lines(linesInFile);
}
else
return -1; // we failed to read in the file.

#else
vector<string> linesInFile;
if (ReadLinesInFile(path, linesInFile)) {
linesInFile = rtrim_empty_lines(linesInFile);
}
else
return -1; // we failed to read in the file.
#endif
numLines = linesInFile.size();

if (IsNDBCWindFile(linesInFile, &numHeaderLines)) {
Expand Down
Loading

0 comments on commit 22720a6

Please sign in to comment.