public static VectorFieldUnsteady LoadTimeSeries(SliceRange[] slices) { ScalarFieldUnsteady[] fields = new ScalarFieldUnsteady[slices.Length]; LoaderRaw loader = new LoaderRaw(RedSea.Variable.VELOCITY_X); for (int i = 0; i < slices.Length; ++i) { fields[i] = loader.LoadTimeSlices(slices[i]); } return(new VectorFieldUnsteady(fields)); }
// string locWFileName = ".0000000108.data"; /// <summary> /// Loads the field using either /// </summary> /// <param name="step"></param> /// <param name="substep"></param> /// <param name="var"></param> /// <returns>Should the NetCDF loader be used?</returns> public static Loader RedSeaLoader(int step, int?substep, int?member, RedSea.Variable var) { string dir = RedSea.Singleton.GetFilename(step, substep, member, var); // Look for raw file. if (substep != null || var == RedSea.Variable.VELOCITY_Z) { var loader = new LoaderRaw(var); loader.Range.SetMember(RedSea.Dimension.TIME, step); loader.Range.SetMember(RedSea.Dimension.SUBTIME, substep ?? 0); loader.Range.SetMember(RedSea.Dimension.MEMBER, member ?? 0); return(loader); } else { return(new LoaderNCF(dir)); } }
private Tuple<FieldPlane, RectlinearGrid> LoadPlaneAndGrid(int member, int time, int subtime = 0, bool timeOffset = false) { LoaderRaw loader = new LoaderRaw(); ScalarField[] scalars;// = new ScalarField[2]; // Read in the data. //_ranges[0].SetMember(RedSea.Dimension.MEMBER, _currentSetting.MemberMain); //_ranges[1].SetMember(RedSea.Dimension.MEMBER, _currentSetting.MemberMain); //LoaderNCF ncFile = RedSea.Singleton.GetLoaderNCF(time); loader.Range.SetMember(RedSea.Dimension.MEMBER, member); loader.Range.SetMember(RedSea.Dimension.TIME, time); loader.Range.SetMember(RedSea.Dimension.SUBTIME, subtime); switch (_currentSetting.Measure) { case RedSea.Measure.VELOCITY: case RedSea.Measure.DIVERGENCE: case RedSea.Measure.VORTICITY: case RedSea.Measure.SHEAR: case RedSea.Measure.DIVERGENCE_2D: scalars = new ScalarField[2]; LoadVelocity: loader.Range.SetMember(RedSea.Dimension.GRID_Z, _currentSetting.SliceHeight); //_variableRanges[(int)RedSea.Variable.VELOCITY_X].SetMember(RedSea.Dimension.MEMBER, member); //_variableRanges[(int)RedSea.Variable.VELOCITY_Y].SetMember(RedSea.Dimension.MEMBER, member); //_variableRanges[(int)RedSea.Variable.VELOCITY_X].SetMember(RedSea.Dimension.CENTER_Z, _currentSetting.SliceHeight); //_variableRanges[(int)RedSea.Variable.VELOCITY_Y].SetMember(RedSea.Dimension.CENTER_Z, _currentSetting.SliceHeight); scalars[0] = loader.LoadFieldSlice(RedSea.Variable.VELOCITY_X); scalars[1] = loader.LoadFieldSlice(RedSea.Variable.VELOCITY_Y); //scalars[0] = ncFile.LoadFieldSlice( _variableRanges[(int)RedSea.Variable.VELOCITY_X]); //scalars[1] = ncFile.LoadFieldSlice(_variableRanges[(int)RedSea.Variable.VELOCITY_Y]); break; default: RedSea.Measure var = _currentSetting.Measure; //_variableRanges[(int)var].SetMember(RedSea.Dimension.MEMBER, member); int sliceHeight = (var == RedSea.Measure.SURFACE_HEIGHT) ? 0 : _currentSetting.SliceHeight; loader.Range.SetMember(RedSea.Dimension.GRID_Z, sliceHeight); //_variableRanges[(int)var].SetMember(RedSea.Dimension.CENTER_Z, _currentSetting.SliceHeight); // Maybe load vector field too. bool addVelocity = (_currentSetting.Shader == FieldPlane.RenderEffect.LIC || _currentSetting.Shader == FieldPlane.RenderEffect.LIC_LENGTH); scalars = new ScalarField[addVelocity ? 3 : 1]; scalars[scalars.Length - 1] = loader.LoadFieldSlice((RedSea.Variable)var); //ncFile.LoadFieldSlice(_variableRanges[(int)var]); if (addVelocity) goto LoadVelocity; break; } //ncFile.Close(); VectorField field; switch (_currentSetting.Measure) { case RedSea.Measure.DIVERGENCE: { VectorField vel = new VectorField(scalars); bool keepField = _currentSetting.Shader == FieldPlane.RenderEffect.LIC; scalars = new ScalarField[keepField ? 3 : 1]; scalars[scalars.Length - 1] = new VectorField(vel, FieldAnalysis.Divergence, 1, true).Scalars[0] as ScalarField; if (keepField) { scalars[0] = vel.Scalars[0] as ScalarField; scalars[1] = vel.Scalars[1] as ScalarField; } break; } case RedSea.Measure.DIVERGENCE_2D: { VectorField vel = new VectorField(scalars); scalars = new VectorField(vel, FieldAnalysis.Div2D, 2, true).Scalars as ScalarField[]; break; } case RedSea.Measure.VORTICITY: { VectorField vel = new VectorField(scalars); bool keepField = _currentSetting.Shader == FieldPlane.RenderEffect.LIC; scalars = new ScalarField[keepField ? 3 : 1]; scalars[scalars.Length - 1] = new VectorField(vel, FieldAnalysis.Vorticity, 1, true).Scalars[0] as ScalarField; if (keepField) { scalars[0] = vel.Scalars[0] as ScalarField; scalars[1] = vel.Scalars[1] as ScalarField; } break; } case RedSea.Measure.SHEAR: { VectorField vel = new VectorField(scalars); bool keepField = _currentSetting.Shader == FieldPlane.RenderEffect.LIC; scalars = new ScalarField[keepField ? 3 : 1]; scalars[scalars.Length - 1] = new VectorField(vel, FieldAnalysis.Shear, 1, true).Scalars[0] as ScalarField; if (keepField) { scalars[0] = vel.Scalars[0] as ScalarField; scalars[1] = vel.Scalars[1] as ScalarField; } break; } default: break; } field = new VectorField(scalars); //loader.Range.SetMember(RedSea.Dimension.TIME, time+1); //var x = loader.LoadFieldSlice(RedSea.Variable.VELOCITY_X); //var y = loader.LoadFieldSlice(RedSea.Variable.VELOCITY_Y); //ScalarFieldUnsteady xS = new ScalarFieldUnsteady(new ScalarField[] { scalars[0], x }); //xS.DoNotScale(); //ScalarFieldUnsteady yS = new ScalarFieldUnsteady(new ScalarField[] { scalars[0], y }); //yS.DoNotScale(); //VectorFieldUnsteady twoSlices = new VectorFieldUnsteady(new ScalarFieldUnsteady[] { xS, yS }); //Console.WriteLine("Remooove meeeeee!"); //VectorFieldUnsteady awriuwergioaheosiohlbyuygowgfuyvbui = new VectorFieldUnsteady(twoSlices, FieldAnalysis.Acceleration, 2); field.TimeSlice = timeOffset ? time * RedSea.Singleton.NumSubsteps + subtime/*time + (float)subtime / RedSea.Singleton.NumSubsteps*/ : 0; // field = new VectorField(velocity, FieldAnalysis.StableFFF, 3, true); RectlinearGrid grid = field.Grid as RectlinearGrid; return new Tuple<FieldPlane, RectlinearGrid>(new FieldPlane(Plane, field, _currentSetting.Shader, _currentSetting.Colormap), grid); }
public MemberComparison(/*LoaderNCF.SliceRange[] ranges,*/ Plane plane) { //Debug.Assert(ranges.Length == 2); //_ranges = ranges; _fields = new FieldPlane[2]; Plane = plane; Mapping = LoadMembers; //LoaderNCF ncFile = RedSea.Singleton.GetLoaderNCF(0); //int sizeVar = ncFile.GetNumVariables(); //_variableRanges = new LoaderNCF.SliceRange[sizeVar]; ////LoaderNCF.SliceRange ensembleU = new LoaderNCF.SliceRange(ncFile, RedSea.Variable.VELOCITY_X); ////ensembleU.SetMember(RedSea.Dimension.TIME, 0); ////LoaderNCF.SliceRange ensembleV = new LoaderNCF.SliceRange(ncFile, RedSea.Variable.VELOCITY_Y); ////ensembleV.SetMember(RedSea.Dimension.TIME, 0); ////LoaderNCF.SliceRange ensembleSal = new LoaderNCF.SliceRange(ncFile, RedSea.Variable.SALINITY); ////ensembleSal.SetMember(RedSea.Dimension.TIME, 0); ////LoaderNCF.SliceRange ensembleTemp = new LoaderNCF.SliceRange(ncFile, RedSea.Variable.TEMPERATURE); ////ensembleTemp.SetMember(RedSea.Dimension.TIME, 0); ////LoaderNCF.SliceRange ensembleHeight = new LoaderNCF.SliceRange(ncFile, RedSea.Variable.SURFACE_HEIGHT); ////ensembleHeight.SetMember(RedSea.Dimension.TIME, 0); ////_variableRanges[(int)RedSea.Variable.VELOCITY_X] = ensembleU; ////_variableRanges[(int)RedSea.Variable.VELOCITY_Y] = ensembleV; ////_variableRanges[(int)RedSea.Variable.SALINITY] = ensembleSal; ////_variableRanges[(int)RedSea.Variable.TEMPERATURE] = ensembleTemp; ////_variableRanges[(int)RedSea.Variable.SURFACE_HEIGHT] = ensembleHeight; //_variableRange = new LoaderRaw.SliceRangeRaw(); //_variableRange.SetMember(RedSea.Dimension.TIME, 0); _loader = new LoaderRaw(); _loader.Range.SetMember(RedSea.Dimension.SUBTIME, 0); //ncFile.Close(); }
// string locWFileName = ".0000000108.data"; /// <summary> /// Loads the field using either /// </summary> /// <param name="step"></param> /// <param name="substep"></param> /// <param name="var"></param> /// <returns>Should the NetCDF loader be used?</returns> public static Loader RedSeaLoader(int step, int? substep, int? member, RedSea.Variable var) { string dir = RedSea.Singleton.GetFilename(step, substep, member, var); // Look for raw file. if (substep != null || var == RedSea.Variable.VELOCITY_Z) { var loader = new LoaderRaw(var); loader.Range.SetMember(RedSea.Dimension.TIME, step); loader.Range.SetMember(RedSea.Dimension.SUBTIME, substep??0); loader.Range.SetMember(RedSea.Dimension.MEMBER, member??0); return loader; } else { return new LoaderNCF(dir); } }
public static VectorFieldUnsteady LoadTimeSeries(SliceRange[] slices) { ScalarFieldUnsteady[] fields = new ScalarFieldUnsteady[slices.Length]; LoaderRaw loader = new LoaderRaw(RedSea.Variable.VELOCITY_X); for (int i = 0; i < slices.Length; ++i) fields[i] = loader.LoadTimeSlices(slices[i]); return new VectorFieldUnsteady(fields); }