Пример #1
0
void CInternalFilesZFXY::CreateDim
		(NetCDFVarKind		Kind,
		 const std::string		&XName,
		 const CExpressionValue	&Values,
		 const std::string		&Units,
		 const std::string		&LongName,
                 const std::string           &Comment /* = ""*/,
      	         double	                ValidMin /* = CTools::m_defaultValueDOUBLE */,
		 double	                ValidMax /* = CTools::m_defaultValueDOUBLE */)
{
  if (m_file.GetNbDimensions() >= 2)
    throw CFileException(CTools::Format("Only two dimensions is allowed in %s file type, not %d",
				        GetType().c_str(),
					m_file.GetNbDimensions()),
			 GetName(),
			 BRATHL_LOGIC_ERROR);
  m_file.SetDimension(Kind, XName, Values.GetNbValues(), Values, Units, LongName, Comment, ValidMin, ValidMax);
}
Пример #2
0
void CInternalFilesYFX::CreateDim
		(NetCDFVarKind kind,
		 const string& xName,
		 const CExpressionValue& values,
		 const string& units,
		 const string& longName,
     const string& comment /* = ""*/,
     double	validMin /* = CTools::m_defaultValueDOUBLE */,
		 double	validMax /* = CTools::m_defaultValueDOUBLE */)
{
  if (m_file.GetNbDimensions() != 0)
  {
    throw CFileException(CTools::Format("Only one dimension is allowed in '%s' file type",
				        GetType().c_str()),
			 GetName(),
			 BRATHL_LOGIC_ERROR);
  }

  m_file.SetDimension(kind, xName, values.GetNbValues(), values, units, longName, comment, validMin, validMax);
}
Пример #3
0
//----------------------------------------
int32_t CBratProcessExportAscii::WriteData()
{
  int32_t result = BRATHL_SUCCESS;
  //CTrace *p = CTrace::GetInstance();

  //p->Tracer(1, "Writing data ...");

  CObArray::iterator itDataSet;
  CRecordSet* recordSet = NULL;

  CDataSet* dataSet = m_product->GetDataSet();

  for (itDataSet = dataSet->begin(); itDataSet != dataSet->end() ; itDataSet++)
  {
    recordSet = dataSet->GetRecordSet(itDataSet);

    ///bool firstRecord = (record == dataSet->front());

    CExpressionValue exprValueSelect;
  
    if (m_alwaysTrue == false)
    {
      recordSet->ExecuteExpression(m_select, m_recordName, exprValueSelect, m_product);
    }

    if (m_writeHeader)
    {
      for (uint32_t indexExpr = 0 ; indexExpr < m_fields.size() ; indexExpr++)
      {
        CExpressionValue exprValueData;
        recordSet->ExecuteExpression(m_fields[indexExpr], m_recordName, exprValueData, m_product);
        
        string colName = (m_names[indexExpr].empty() ? m_fields[indexExpr].AsString() : m_names[indexExpr]);

        string unitStr;
        unitStr.append(" (");
        unitStr.append(m_units[indexExpr].AsString(false, true));
        unitStr.append(") ");

        if (m_units[indexExpr].IsDate() && !m_dateAsPeriod )
        {
          unitStr = "";
        }

        if (m_units[indexExpr].IsDate() && !m_units[indexExpr].HasDateRef() )
        {
          unitStr = "";
        }

        *m_outputFile << colName << unitStr  << " " << exprValueData.GetDimensionsAsString() << "\t";
      }
      *m_outputFile << endl;
      m_writeHeader = false;
    }

    if (m_alwaysTrue == false)
    {
      if (exprValueSelect.IsTrue() != 1)
      {
        //Data doesn't match SELECT options,
        //-------------
        continue;
        //-------------
      }
    }

    for (uint32_t indexExpr = 0 ; indexExpr < m_fields.size() ; indexExpr++)
    {
      CExpressionValue exprValueData;
      recordSet->ExecuteExpression(m_fields[indexExpr], m_recordName, exprValueData, m_product);

      *m_outputFile << exprValueData.AsString(m_units[indexExpr], m_formats[indexExpr], m_dateAsPeriod) << "\t";
    }
    *m_outputFile << endl;

  }

  //p->Tracer(1,"End writing data ...");

  return result;
}
Пример #4
0
//----------------------------------------
void CBratAlgoFilterKernel::PrepareDataWindow2DSymmetrically(CExpressionValue& exprValue, uint32_t shiftSymmetry /* = 0 */)
{
  PrepareDataWindow2DSymmetrically(exprValue.GetValues(), exprValue.GetNbValues(), shiftSymmetry);
}
Пример #5
0
//----------------------------------------
void CXYPlotPanel::SetAnimationDescr(uint32_t indexValue)
{
  if (m_plotDataCollection == NULL)
  {
    return;
  }

 // glbSizerAnimationDescr->Hide(m_animationToolbar->GetDescr());
  m_animationToolbar->GetDescr()->SetLabel("");
  if (m_plotDataCollection->size() <= 0)
  {
    return;
  }

  wxString descr;

  uint32_t nData = m_plotDataCollection->size();

  for (uint32_t i = 0 ; i < nData ; i++)
  {

    CXYPlotData* data = m_plotDataCollection->Get(i);

    if (data->GetVarComplement().GetNbValues() <= 0)
    {
      continue;
    }

    CFieldNetCdf& field = data->GetFieldComplement();
    string fieldDescr = field.GetMostExplicitName();
    string strUnit = field.GetUnit();

    CUnit* unit = field.GetNetCdfUnit();
  
    uint32_t index = indexValue;
    if (index >= data->GetVarComplement().GetNbValues())
    {
      index = data->GetVarComplement().GetNbValues() - 1;
    }
    if (unit->IsDate())
    {
      CDate d1950_01_01 = unit->ConvertToBaseUnit(data->GetVarComplement().GetValues()[index]);
    
      descr.Append(wxString::Format("'%s' value for above plot: %s (field '%s')\n", 
                               fieldDescr.c_str(), 
                               d1950_01_01.AsString("", true).c_str(),
                               data->GetName().c_str()));

    }
    else
    {
      descr.Append(wxString::Format("'%s' value for above plot: %f %s (field '%s')\n", 
                               fieldDescr.c_str(), 
                               data->GetVarComplement().GetValues()[index],
                               strUnit.c_str(),
                               data->GetName().c_str()));
    }


    uint32_t iOtherFields = 0;

    const CObArray& otherFields = data->GetOtherFields();
    //const vector<CExpressionValue>& otherData = data->GetOtherVars();
    const CObArray& otherData = data->GetOtherVars();
    
    //otherFields.Dump(*(CTrace::GetInstance()->GetDumpContext()));

    for (iOtherFields = 0 ; iOtherFields < otherFields.size() ; iOtherFields++)
    {
      CFieldNetCdf* field = dynamic_cast<CFieldNetCdf*>(otherFields.at(iOtherFields));
      if (field == NULL)
      {
        continue;
      }

      string fieldDescr = field->GetMostExplicitName();
      string strUnit = field->GetUnit();

      CUnit* unit = field->GetNetCdfUnit();

      uint32_t index = indexValue;
      CExpressionValue* exprValue = CExpressionValue::GetExpressionValue(otherData.at(iOtherFields));

      if (index >= exprValue->GetNbValues())
      {
        index = exprValue->GetNbValues() - 1;
      }

      if (unit->IsDate())
      {
        CDate d1950_01_01 = unit->ConvertToBaseUnit(exprValue->GetValues()[index]);
  
        descr.Append(wxString::Format("'%s' value for above plot: %s (field '%s')\n", 
                                 fieldDescr.c_str(), 
                                 d1950_01_01.AsString("", true).c_str(),
                                 data->GetName().c_str()));

      }
      else
      {
        double value = exprValue->GetValues()[index];
        wxString valueStr;

        if (CTools::IsDefaultValue(value))
        {
          valueStr = "No value (default value)";
        }
        else
        {
          valueStr = wxString::Format("%f %s", value, strUnit.c_str());
        }

        descr.Append(wxString::Format("'%s' value for above plot: %s (field '%s')\n", 
                                 fieldDescr.c_str(), 
                                 valueStr.c_str(),
                                 data->GetName().c_str()));
      }

    }
  }


  m_animationToolbar->GetDescr()->SetLabel(descr);

}