public void FilterAndJoin() { //filter subjects by arms if (Arms.Any()) { Subjects = Subjects.FindAll(s => Arms.Select(a => a.Id).Contains(s.StudyArmId)).ToList(); } Debug.WriteLine(Subjects.Count, " AFTER ARMS"); //filter subjects by studies if (Studies.Any()) { Subjects = Subjects.FindAll(subj => Studies.Select(st => st.Id).Contains(subj.StudyId)).ToList(); } Debug.WriteLine(Subjects.Count, " AFTER Studies"); //filter subjects by subCharacteristics if (SubjChars.Any()) { Subjects = Subjects.FindAll(s => SubjChars.Select(sc => sc.SubjectId).Contains(s.Id)).ToList(); } Debug.WriteLine(Subjects.Count, " AFTER SubjChars"); //filter by visits //TODO //TODO : WILL RETRIEVE SUBJECTS THAT HAVE SAME UNIQUE IDS ACROSS PROJECTS (i.e. need to load observations to Mongo with //TODO: DB subjectId //filter observations for filtered subjects Observations = Observations?.FindAll(o => Subjects.Select(s => s.UniqueSubjectId).Contains(o.USubjId)); //filter subjects by selected observations if (Observations.Any() && ObservationsFiltered) { Subjects = Subjects.FindAll(s => Observations.Select(o => o.USubjId).Contains(s.UniqueSubjectId)); } Debug.WriteLine(Subjects.Count, " AFTER syncing with observations"); //FILTER SAMPLES BY SELECTED AND FILTERED SAMPLE CHARACTERISTICS if (SampleCharacteristics.Any()) { Samples = Samples.FindAll(s => SampleCharacteristics.Select(sc => sc.SampleId).Contains(s.Id)).ToList(); } //TODO: TEMP FILTERING BY COLLECTION STUDY DAY //SYNCHRONIZE SAMPLES AND SUBJECTS if (Samples.Any()) { Samples = Samples.FindAll(s => Subjects.Select(sc => sc.Id).Contains(s.SubjectId)).ToList(); Subjects = Subjects.FindAll(sb => Samples.Select(sp => sp.SubjectId).Contains(sb.Id)).ToList(); } }
public override bool Load(ICancelProgressHandler progresshandler) { if (File.Exists(FileName)) { var grid = (Owner.Grid as MFGrid); Observations.Clear(); StreamReader sr = new StreamReader(FileName); var line = ReadComment(sr); var strs = TypeConverterEx.Split <string>(line, 6); NH = int.Parse(strs[0]); MOBS = int.Parse(strs[1]); MAXM = int.Parse(strs[2]); IUHOBSV = int.Parse(strs[3]); HOBDRY = float.Parse(strs[4]); Option = strs[5]; TOMULTH = TypeConverterEx.Split <float>(sr.ReadLine(), 1)[0]; Topology = new RegularGridTopology(); int i = 0; while (!sr.EndOfStream) { line = sr.ReadLine(); var vv = TypeConverterEx.SkipSplit <float>(line, 1, 8); strs = TypeConverterEx.Split <string>(line); HeadObservation obs = new HeadObservation(i) { Layer = (int)vv[0], Row = (int)vv[1], Column = (int)vv[2], IREFSPFlag = (int)vv[3], Name = strs[0] }; obs.CellID = grid.Topology.GetID(obs.Row - 1, obs.Column - 1); if (obs.IREFSPFlag < 0) { line = sr.ReadLine(); obs.ITT = TypeConverterEx.Split <int>(line, 1)[0]; int nsp = Math.Abs((int)vv[3]); obs.IREFSP = new int[nsp]; obs.TOFFSET = new float[nsp]; obs.HOBS = new float[nsp]; obs.ROFF = vv[5]; obs.COFF = vv[6]; for (int t = 0; t < nsp; t++) { line = sr.ReadLine(); vv = TypeConverterEx.SkipSplit <float>(line, 1, 4); obs.IREFSP[t] = (int)vv[0]; obs.TOFFSET[t] = vv[1]; obs.HOBS[t] = vv[2]; } } else { int nsp = 1; obs.IREFSP = new int[nsp]; obs.TOFFSET = new float[nsp]; obs.HOBS = new float[nsp]; obs.IREFSP[0] = (int)vv[3]; obs.TOFFSET[0] = vv[4]; obs.ROFF = vv[5]; obs.COFF = vv[6]; obs.HOBS[0] = vv[7]; } obs.Elevation = grid.GetElevationAt(obs.Row - 1, obs.Column - 1, obs.Layer - 1); Observations.Add(obs); i++; } if (Observations.Any()) { Topology.ActiveCell = new int[NH][]; Topology.ActiveCellIDs = new int[NH]; Topology.RowCount = grid.RowCount; Topology.ColumnCount = grid.ColumnCount; Topology.ActiveCellCount = NH; var nsp1 = (Observations[0] as HeadObservation).IREFSP.Length; HOBS = new DataCube <float>(1, nsp1, NH); HOBS.Variables = new string[] { "Head Observation" }; for (int t = 0; t < nsp1; t++) { for (int k = 0; k < NH; k++) { var hob = Observations[k] as HeadObservation; HOBS[0, t, k] = hob.HOBS[t]; Topology.ActiveCell[k] = new int[] { hob.Row - 1, hob.Column - 1 }; Topology.ActiveCellIDs[k] = grid.Topology.GetID(hob.Row - 1, hob.Column - 1); } } HOBS.Topology = this.Topology; } sr.Close(); OnLoaded(progresshandler); return(true); } else { OnLoadFailed("Failed to load " + this.Name, progresshandler); return(false); } }